<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
通过management.endpoint.shutdown.enabled
参数来进行设置,默认为false
,默认不会开启远程关闭服务
功能,然后把shutdown
节点进行开放,否则无法发送远程关机
请求。
# 管理节点配置
management:
endpoints:
web:
# actuator的前缀地址
base-path: /
# 开放指定节点
exposure:
include:
- health
- info
- mappings
- env
- shutdown
# 开启远程关闭服务
endpoint:
shutdown:
enabled: true
postman工具发送post请求
curl -X POST http://localhost:8080/shutdown
我们去查看对应的服务实例运行状态
时可以发现已经停止了。
{"message":"Shutting down, bye..."}