Spring配置初始化方法

DD.*_*DD. 8 java spring spring-3

如何告诉Spring运行该init方法?我需要获取Proxied Async类并使用它进行一些初始化.

@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 "";
 }

}
Run Code Online (Sandbox Code Playgroud)

Jus*_*KSU 13

你可以使用@PostConstruct