Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring Boot Maven plugin - spring-boot:run and graceful shutdown

I can run a Spring Boot application with a following Maven command:

mvn spring-boot:run 

but I don't know how to do a graceful shutdown of application which was started in a such way. Please advise.

like image 748
alexanoid Avatar asked Jul 31 '17 21:07

alexanoid


People also ask

How do you gracefully shutdown a spring boot application?

In the Spring Boot Document, they said that 'Each SpringApplication will register a shutdown hook with the JVM to ensure that the ApplicationContext is closed gracefully on exit. ' When I click ctrl+c on the shell command, the application can be shutdown gracefully.

Which of the following interface is used for graceful shutdown of spring boot application context?

Close ApplicationContext Another option to shutdown Spring Boot application is to close Spring ApplicationContext using SpringApplication . SpringApplication#run(String…) method returns ApplicationContext as a < ConfigurableApplicationContext. We can use close() method to close ApplicationContext programmatically.

Why does my spring boot app keep closing?

We know that a Spring Boot web app needs an embedded servlet container on the classpath. The app will shut down if it doesn't find any of the embedded servlet containers. To resolve the unexpected shut down during startup, we need to obtain a fully configured instance using the appropriate Starter.


1 Answers

To gracefully exit your application simply hit ctrl-c in your terminal.

Or you can use mvn spring-boot:start to start you app in background and mvn spring-boot:stop to shutdown gracefuly.

like image 200
Sébastien Helbert Avatar answered Oct 11 '22 21:10

Sébastien Helbert