我有春天的应用程序(我没有懒的豆子).
当所有@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 } }