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

2024-12-02 11:28:21
推荐回答(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;
}