spring-boot-CommandLineRunner

在项目服务启动完成后就去加载一些数据

@Component
public class MyStartupRunner1 implements CommandLineRunner {
    @Override
    public void run(String... args) throws Exception {
        System.out.println(">>>>>>>>>>>>>>>服务启动执行,执行加载数据等操作<<<<<<<<<<<<<");
    }
}

也可以利用@Order注解(或者实现Order接口)来规定所有CommandLineRunner实例的运行顺序。

posted @ 2018-12-10 16:14  张建斌  阅读(289)  评论(0编辑  收藏  举报