PostConstruct注解作用
时间: 2023-10-17 22:26:03 浏览: 87
注解的使用
PostConstruct注解的作用是指定一个方法,在Spring实例化该Bean之后立即执行。被@PostConstruct修饰的方法会在服务器加载Servlet的时候运行,并且只会被服务器执行一次。这个注解通常用于初始化操作,例如数据库连接的初始化、资源加载等。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [最快讲一个spring注解:@PostConstruct](https://blog.csdn.net/a24b86/article/details/105146855)[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_1"}}] [.reference_item style="max-width: 50%"]
- *2* *3* [@PostConstruct注解及用处示例](https://blog.csdn.net/yfyh2021/article/details/121930899)[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_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文