File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed
web/src/main/java/demo/web/config Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change
1
+ package demo .web .config ;
2
+
3
+ import org .springframework .boot .CommandLineRunner ;
4
+ import org .springframework .core .annotation .Order ;
5
+ import org .springframework .stereotype .Component ;
6
+
7
+ /**
8
+ * parent
9
+ * demo.web.config
10
+ * Spring Boot的CommandLineRunner接口主要用于实现在应用初始化后,去执行一段代码块逻辑,如初始化数据等
11
+ * 这段初始化代码在整个应用生命周期内只会执行一次。
12
+ *
13
+ * @author BlueDriver
14
+ * @email cpwu@foxmail.com
15
+ * @date 2019/06/05 09:01 Wednesday
16
+ * 参考:https://www.cnblogs.com/chenpi/p/9696310.html
17
+ */
18
+ @ Component
19
+ @ Order (1 )//如果有多个实现CommandLineRunner的类,指定执行顺序,会从小到大一次执行
20
+ public class ApplicationStartupRunner implements CommandLineRunner {
21
+ @ Override
22
+ public void run (String ... args ) throws Exception {
23
+ System .err .println (">>>>>>>>>>>>>>>服务启动后执行,可用户执行初始化数据等操作<<<<<<<<<<<<" );
24
+ }
25
+ }
You can’t perform that action at this time.
0 commit comments