SpringBoot启动之后立即执行
一个是ApplicationRunner
另一个是CommandLineRunner
还可以用AoolicationListener<ApplicationReadyEvent> 上面两种需要记住
具体使用
具体执行的顺序
默认情况下 ApplicationRunner比CommandLineRunner先执行
但是如果用@Order 指定下顺序的话 可以反过来
而ApplicationListener是肯定再ApplicationRunner和CommandLineRunner之后执行
最后才是SpringBoot的main方法里的run之后的代码
上面是SpringBoot启动后执行的
下面是SpringBoot启动前执行的
@PostConstruct注解
它是在SpringBoot启动前就执行了