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