How does a Spring Boot console based application work?

孤人 提交于 2019-11-28 16:59:51

You should have a standard loader:

@SpringBootApplication
public class MyDemoApplication {
    public static void main(String[] args) {
        SpringApplication.run(MyDemoApplication.class, args);
    }
}

and implement a CommandLineRunner interface with @Component annotation

    @Component
    public class MyRunner implements CommandLineRunner {

       @Override    
       public void run(String... args) throws Exception {

      }
   }

@EnableAutoConfiguration will do the usual SpringBoot magic.

UPDATE:

As @jeton suggests the laters Springboot implements a straight:

spring.main.web-environment=false
spring.main.banner-mode=off

See docs at 72.2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!