spring类初始化后执行方法


  1. 实现接口InitializingBean实现afterPropertiesSet方法
  2. 基于注解@PostConstruct
@PostConstruct
public void init(){
    System.out.println("........")
}

 

构造器、@PostConstruct、InitializingBean、BeanPostProcessor接口执行顺序

1、执行无参构造函数

2、执行被@postConstruct注解的方法

3、执行InitializingBean 的 afterPropertiesSet方法

4、执行BeanPostProcessor 的postProcessBeforelnitialization方法

5、执行BeanPostProcessor的postProcessAfterlnitialization方法


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM