spring boot 官方guides中的/actuator/shutdown

spring boot 官方guides中的

There is also a /actuator/shutdown endpoint, but it’s only visible by default via JMX. To enable it as an HTTP endpoint, add management.endpoints.shutdown.enabled=true to your application.properties file.

也就是说,我们可以通过localhost:8080/actuator/shutdown来停止服务器。当然这个功能开起来风险比较大。但官网提出来了,个人想试试。但按照官网的方法,在application.properties中添加management.endpoints.shutdown.enabled=true不好用。在网上找了半天资料,结合自己的尝试成功了,在此分享一下。
总共分2步
第一步:在application.properties中添加如下代码
#启用shutdown
management.endpoint.shutdown.enabled=true
#开启所有的端点
management.endpoints.web.exposure.include=*

这时候我们请求,后台会提示 Request method ‘GET’ not supported。也就是说不支持get请求,我们需要用post.

第二步:按照官网的说明,执行$ curl -X POST localhost:8080/actuator/shutdown
windows在cmd中执行即可。
这时候,就会提示 {“message”:“Shutting down, bye…”}。

再访问应用,就已经停掉了。

  • 5
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值