Spring初始化监听

 1 @Repository
 2 public class InitSmsThread implements ApplicationListener<ContextRefreshedEvent> {
 3         
 4         public void onApplicationEvent(ContextRefreshedEvent event) {
 5             if(event.getApplicationContext().getParent() == null){//root application context 没有parent,他就是老大.
 6                  //需要执行的逻辑代码,当spring容器初始化完成后就会执行该方法。
 7             }
 8             
 9         }
10 
11 }

 

posted @ 2016-01-13 13:19  我是魏星星  阅读(348)  评论(0编辑  收藏  举报