SpringBoot(三) ---- SpringBoot启动加载器
1.ApplicationRunner
实现ApplicationRunner接口,覆盖run方法,并注册成bean:
@Component @Order(1) public class TestApplicationRunner implements ApplicationRunner { @Autowired SystemInitService systemInitService; @Override public void run(ApplicationArguments args) throws Exception { systemInitService.systemInit(); }
可以使用order注解控制执行顺序,越小越优先。