Configuration 和 Bean 注解 | LIXI.FUN
0%

Configuration 和 Bean 注解

主要关注一点,@Configruation 注解中的 proxyBeanMethods 属性默认为 true,也就是说在此 Config 类中调用被 @Bean 注解的方法,每次返回的都是同一个 bean 实例。

@Component 则没有这种特性。

详情可以参考 spring-configuration-bean-annotation-test 中的测试代码,自己运行下。

觉得有收获就鼓励下作者吧