在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库

 

相关文章:

  • 2021-07-11
  • 2021-08-31
  • 2021-04-27
  • 2021-12-15
  • 2021-12-14
  • 2021-04-16
  • 2021-10-27
猜你喜欢
  • 2021-06-30
  • 2021-05-29
  • 2021-05-13
  • 2021-07-19
  • 2022-12-23
  • 2021-12-11
  • 2021-06-14
相关资源
相似解决方案