Spring when the project started, if you need to initialize resources, can achieve ApplicationRunner or CommandLineRunner, and can use annotation @Order specify their running order.
Sample Code: https://github.com/rickding/HelloJava/tree/master/HelloRunner
3 types of documents:
RunnerApplication.java achieve SpringBootApplication main program:
HelloApplicationRunner.java achieve ApplicationRunner:
HelloCommandLineRunner.java achieve CommandLineRunner, and specifies @Order (1):
Output log:
Reference article: https://blog.csdn.net/qq_28804275/article/details/80891941