Wednesday, March 23, 2022

Shutdown Spring Boot Command Line Application

You can use ConfigurableApplicationContext to shutdown/closes all resources used by application as follows.

 public static void main(String[] args) {

        ConfigurableApplicationContext ctx=SpringApplication.run(Application.class, args);

        ctx.close();

    } 

    @Bean

    public CommandLineRunner commandLineRunner(RestTemplate restTemplate) {

        return args -> {

}

    }


No comments:

Post a Comment