当前位置:   article > 正文

springboot actuator shutdown正确的关闭操作

actuator 关闭返回 links self

今天整合ehcache时发现一个很重要的问题,就是程序关闭(硬关闭)之后,持久化到磁盘的缓存数据没能正确写入加载,问题还是硬关闭的问题,所以就使用actuator 进行监听

<dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

application.properties中添加(这里使用的是springboot2.x,所以management.endpoint替换了1.x的endpoints)

#启用shutdown

management.endpoint.shutdown.enabled=true

重启之后(/actuator 查看添加的监听接口)发现是没有需要的(/shutdown)

{
    "_links": {
        "self": {
            "href": "http://localhost:8082/actuator",
            "templated": false
        },
        "health": {
            "href": "http://localhost:8082/actuator/health",
            "templated": false
        },
        "info": {
            "href": "http://localhost:8082/actuator/info",
            "templated": false
        }
    }
}

application.properties中添加

management.endpoints.web.exposure.include=*

(/actuator/shutdown)正常返回

{
    "message": "Shutting down, bye..."
}

 修改默认(/actuator)前缀路径)application.properties中添加

management.endpoints.web.base-path=/system/actuator

 

转载于:https://www.cnblogs.com/skyLogin/p/9214575.html

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/2023面试高手/article/detail/334177
推荐阅读
相关标签
  

闽ICP备14008679号