DEV Community

MJ
MJ

Posted on

Shutdown Spring Boot command-line application

If you have a SpringBootApplication which implements the CommandLineRunner interface and wish to terminate it after running the override run method, here is it:

@SpringBootApplication public class DemoApplication implements CommandLineRunner { SpringApplication app = new SpringApplicationBuilder() .sources(DemoApplication.class) .web(false).build(); springApplication.run(args).close(); @Overrride public void run(String... strings) throws Exception { // Code } } 

Top comments (0)