我該如何告訴Spring運行init方法?我需要獲得Proxied Async類並使用它進行一些初始化。Spring配置Init方法
@Configuration
@EnableAsync
public class Config {
@Bean
public AsyncBean asyncProxyBean(){
return new AsyncBean();
}
public void init(){
doStuffWithProxy(asyncProxyBean());
}
@Bean
public String thisIsHack(){ //this runs the init code but bean is a bit hacky
doStuffWithProxy(asyncProxyBean());
return "";
}
}
在我的情況下,代理是一個AsyncEventHandler,我需要註冊與事件生產者的處理程序。 – 2012-01-04 22:35:41