官方介绍
官网
Spring Boot 2.3.0 available now
Graceful shutdown
Graceful shutdown is supported with all four embedded web servers (Jetty, Reactor Netty, Tomcat, and Undertow) and with both reactive and Servlet-based web applications. When a grace period is configured, upon shutdown, the web server will no longer permit new requests and will wait for up to the grace period for active requests to complete.
使用
#开启优雅关闭 服务器将支持的关闭类型 : GRACEFUL:优雅 IMMEDIATE:即时
server.shutdown=GRACEFUL
#关闭缓冲时间 任何阶段(具有相同“阶段”值的 SmartLifecycle bean 组)关闭的超时时间
spring.lifecycle.timeout-per-shutdown-phase=15s