Spring项目初始化

需要实现 ApplicationListener<ContextRefreshedEvent>

@Component
public class CrawlerInitialize implements ApplicationListener<ContextRefreshedEvent> {
    @Override
    public void onApplicationEvent(ContextRefreshedEvent event) {
        CrawlerWebsiteService crawlerWebsiteService = SpringContextHolder.getBean(CrawlerWebsiteService.class);
        crawlerWebsiteService.initCrawlerStatus(StatusEnum.STOP.getValue());
    }
}

猜你喜欢

转载自my.oschina.net/u/3669033/blog/1816171