@PostConstruct
时间: 2023-08-26 08:18:26 浏览: 75
SpringBoot @PostConstruct原理用法解析
@PostConstruct是一个注解,用于指定在bean初始化完成后要执行的方法。该注解通常与Spring框架中的依赖注入相关的类一起使用,比如在UserController类中,可以使用@PostConstruct注解来标记一个方法,该方法将在UserService注入完成后自动执行。被@PostConstruct修饰的方法会在服务器加载Servlet的时候运行,并且只会被服务器执行一次。这个注解可以用于一些常规化加载数据的操作,比如加载数据字典等。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [SpringBoot中@PostConstruct注解作用](https://blog.csdn.net/qq_45335399/article/details/126885872)[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^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *2* [@PostConstruct注解详解](https://blog.csdn.net/m0_53288098/article/details/122355201)[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^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *3* [@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^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
[ .reference_list ]
阅读全文