spring3 怎么通过注解方式把接口注入

2024年12月02日 11:28
有1个网友回答
网友(1):


scoped-proxy="interfaces" />



@Bean
@Scope(value = "session", proxyMode = ScopedProxyMode.INTERFACES)
public UserPreferences userPreferences() {
return new UserPreferences();
}
@Bean
public Service userService() {
UserService service = new SimpleUserService();
// a reference to the proxied userPreferences bean
service.setUserPreferences(userPreferences());
return service;
}