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库

 

posted @ 2018-10-28 15:20  platycoden  阅读(2840)  评论(0编辑  收藏  举报