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库

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM