@Configuration public class AppConfig { @Bean(initMethod = "init") public Foo foo() { return new Foo(); } @Bean(destroyMethod = "cleanup") public Bar bar() { return new Bar(); } }
上述代码中initMethod和destroyMethod后面没有括号。
记住千万不要带括号。
注意@Bean中的initMethod和destroyMethod
原文:http://www.cnblogs.com/1540340840qls/p/7931816.html