SpringBoot(12) SpringBoot创建非web应用
在Spring Boot中,要创建一个非Web应用程序,实现CommandLineRunner并覆盖run()方法
1 @SpringBootApplication 2 public class SpringBootConsoleApplication implements CommandLineRunner { 3 4 public static void main(String[] args) throws Exception { 5 6 SpringApplication.run(SpringBootConsoleApplication.class, args); 7 8 } 9 10 //access command line arguments 11 @Override 12 public void run(String... args) throws Exception { 13 //do something 14 } 15 }
pom依赖:spring-boot-starter库