简体   繁体   中英

How to gracefully shutdown a Spring Boot application?

Is there any difference between springapplication.registerShutdownhook() () and Springapplication.exit(applicationcontext) ? Will either of them also shut down the JVM gracefully?

If you have a ConfigurableApplicationContext , you can use the method registerShutdownHook() to register a shutdown hook with the JVM runtime. You can see more here. http://docs.oracle.com/javase/8/docs/api/java/lang/Runtime.html?is-external=true#addShutdownHook-java.lang.Thread-

You use Springapplication.exit(applicationcontext) to close the application context an finish the Spring application.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM