SpringBoot引入监听器

方法一:

实现CommandLineRunner 接口

@Component
@Order(1)
public class AppReadyListener implements CommandLineRunner {

@Override
public void run(String... args) throws Exception {

}
}

方法二:

实现ApplicationRunner 接口

@Component
@Order(2)
public class FinishListener implements ApplicationRunner {

@Override
public void run(ApplicationArguments args) throws Exception {

}
}
posted @ 2019-05-29 20:11  有追求的程序员  阅读(611)  评论(0编辑  收藏  举报