spring初始化

* Created by litao on 15/12/29.
*/
@Component("initTagDataProcessor")
public class InitTagDataProcessor implements ApplicationListener<ContextRefreshedEvent> {
private static Logger logger=Logger.getLogger(InitTagDataProcessor.class);

@Autowired
private AppTagCollectionService appTagCollectionService;

@Override
public void onApplicationEvent(ContextRefreshedEvent event) {
if(event.getApplicationContext().getParent() == null){//root application context 没有parent,他就是老大.
//初始化tag
logger.info("start init tag data");
appTagCollectionService.loadTagData();
logger.info("finish init tag data");
}
}
}

posted @ 2015-12-30 15:34  黎明露珠  阅读(199)  评论(0编辑  收藏  举报