PostConstruct 执行顺序
时间: 2023-09-22 19:12:48 浏览: 155
@PostConstruct注解修饰的方法会在服务器加载Servlet时运行,在构造函数之后执行,init()方法之前执行。通常情况下,PostConstruct的执行顺序如下:Constructor(构造方法) -> @Autowired(依赖注入) -> @PostConstruct(注解的方法)。这意味着在该类的构造方法执行完毕后,依赖注入完成后,才会执行被@PostConstruct修饰的方法。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [@PostConstruct的作用,以及加载先后顺序](https://blog.csdn.net/libralee233/article/details/122681608)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *2* [InitializingBean、BeanPostProcessor、init-method、@PostConstruct执行先后顺序](https://blog.csdn.net/Asa_Prince/article/details/118342171)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *3* [java面试题20道(适合工作1~3年)(附答案).docx](https://download.csdn.net/download/yijian1992/11490469)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"]
[ .reference_list ]
阅读全文