注意@Bean中的initMethod和destroyMethod

Posted 技术让世界更精彩

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了注意@Bean中的initMethod和destroyMethod相关的知识,希望对你有一定的参考价值。

@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的主要内容,如果未能解决你的问题,请参考以下文章