相同点:
InitializingBean,init-method,postConstruct三者都在bean实例化后调用。
不同点:
InitializingBean:
The org.springframework.beans.factory.InitializingBean interface allows a bean to perform initialization work after all necessary properties on the bean have been set by the container. The InitializingBean interface specifies a single method:
void afterPropertiesSet() throws Exception;postConstruct:
The JSR-250 @PostConstruct Using this annotation means that your beans are not coupled to Spring specific interfaces
init-method:
In the case of XML-based configuration metadata, you use the init-method attribute to specify the name of the method that has a void no-argument signature.
如果三者都配置,执行顺序:
Constructor > @PostConstruct > InitializingBean > init-method