创建一个组件类并继承CommandLineRunner接口,实现接口的run方法,

SpringBoot的CommandLineRunner使用_程序运行

然后添加@Order注解指定启动顺序,用同样的方法创建第二个组件类

SpringBoot的CommandLineRunner使用_程序运行_02

 在启动配置中添加程序运行时参数 

SpringBoot的CommandLineRunner使用_程序运行_03

看到两个runner按照指定的启动顺序成功启动了,并输出了传入的参数  

SpringBoot的CommandLineRunner使用_程序运行_04