- SpringBoot之CommandLineRunner使用
- SpringBoot之CommandLineRunner与App
- SpringBoot(十四):CommandLineRunner
- Spring Boot 2 - 使用CommandLineRun
- SpringBoot启动时,执行初始化方法的几种方式
- 【SpringBoot2.0系列05】SpringBoot之整合
- 【SpringBoot2.0系列04】SpringBoot之使用
- 【SpringBoot2.0系列03】SpringBoot之使用
- 【SpringBoot2.0系列02】SpringBoot之使用
- Springboot的 CommandLineRunner 接
/**
* Interface used to indicate that a bean should <em>run</em> when it is contained within
* a {@link SpringApplication}. Multiple {@link CommandLineRunner} beans can be defined
* within the same application context and can be ordered using the {@link Ordered}
* interface or {@link Order @Order} annotation.
*
* 接口被用作将其加入spring容器中时执行其run方法。多个CommandLineRunner可以被同时执行在同一个spring上下文中并且执行顺序是以order注解的参数顺序一致。
*
* If you need access to {@link ApplicationArguments} instead of the raw String array
* consider using {@link ApplicationRunner}.
* 如果你需要访问ApplicationArguments去替换掉字符串数组,可以考虑使用ApplicationRunner类。
*/
CommandLineRunner接口 的Component 会在所有的Spring Beans 都初始化之后,SpringApplication.run() 之前执行,适合应用程序启动之初的数据初始化工作。
![](https://img.haomeiwen.com/i3974683/79a897ca38196d78.png)
网友评论