背景 springboot 2.3.4
1.maven 添加
<groupId>org.springframework.boot
<artifactId>spring-boot-starter-actuator
</dependency>
2. 配置文件添加内容:
#启用shutdown
management.endpoint.shutdown.enabled=true
management.endpoints.web.exposure.include=shutdown
server.shutdown=graceful
spring.lifecycle.timeout-per-shutdown-phase=20s
3. 查看所有url列表
http://IP:端口/actuator
4.执行关机操作
curl -X POST http://localhost:8083/actuator/shutdown
{"message":"Shutting down, bye..."}