java – 在spring初始化所有bean时捕捉时间
发布时间:2020-12-14 05:32:21 所属栏目:Java 来源:网络整理
导读:我有春天的应用程序(我没有懒的豆子). 当所有@Component(@Repositoey @Service @Controller)bean被初始化时,我想插入逻辑. 我该怎么做? 解决方法 如 this question的答案所述,您可以使用ApplicationListener并查找 ContextRefreshedEvent: public class Lo
我有春天的应用程序(我没有懒的豆子).
当所有@Component(@Repositoey @Service @Controller)bean被初始化时,我想插入逻辑. 我该怎么做? 解决方法
如
this question的答案所述,您可以使用ApplicationListener并查找
ContextRefreshedEvent:
public class Loader implements ApplicationListener<ContextRefreshedEvent>{ public void onApplicationEvent(ContextRefreshedEvent event) { // whatever you want to do when app context is initialized or refreshed } } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |