② Bean的afterPropertiesSet不能使用@PostConstruct注释。 init-method注意事项: ① init-method指定属性不能为空。 ② Bean不可以实现InitializingBean接口或Bean的init-method方法名不可以为afterPropertiesSet。 ③ Bean的init-method方法不能使用@PostConstruct注释。 @PostCon...
Constructor > @PostConstruct > InitializingBean > init-method 先大致分析下为什么会出现这些的结果:构造器(Constructor)被率先调用毋庸置疑,InitializingBean先于init-method我们也可以理解(在也谈Spring容器的生命周期中已经讨论过),但是PostConstruct为何率先于InitializingBean执行呢? 我们再次带着这个疑问去查看Spring源代码...