SpringBoot框架常用类

SpringBoot框架常用类
郭顺发记录SpringBoot 常用类,作用和用法。
1. CommandLineRunner(接口) 项目构建 预加载
ApplicationRunner 同理。有时间总结两者的区别。
在使用SpringBoot构建项目时,有一些预先数据的加载。
demo:
1 | public class Run01 implements CommandLineRunner { public void run(String... args) throws Exception { System.out.println("run01"); }}public class Run02 implements CommandLineRunner { public void run(String... args) throws Exception { System.out.println("run02"); }} |
输出:
1 | run01 |