【问题标题】:How to make Spring Boot v2.0.0.M7 Actuator's shutdown work?如何使 Spring Boot v2.0.0.M7 Actuator 的关闭工作?
【发布时间】:2018-06-19 22:31:49
【问题描述】:

我创建了 hello world Spring Boot v2.0.0.M7 应用程序,添加了执行器,启用了关闭功能,但它无法正常工作。

application.properties

server.port=8082
endpoint.shutdown.enabled=true
endpoint.shutdown.sensitive=false

健康状况良好

但不是关机

我做错了什么?

【问题讨论】:

标签: spring-boot spring-boot-actuator


【解决方案1】:

春季启动版本:2.0.1.RELEASE

pom.xml

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

application.properties

management.endpoints.web.exposure.include=shutdown
management.endpoint.shutdown.enabled=true

那么,试试

$ curl -X POST localhost:8080/actuator/shutdown

【讨论】:

    【解决方案2】:

    spring-boot 2.0 默认
    management.endpoints.web.exposure.include=info, health,
    更改为
    management.endpoints.web.exposure.include=info, health, shutdown

    【讨论】:

      【解决方案3】:

      端点在 Spring Boot 2.0 中发生了很大变化,因此,您的配置已过时。您需要启用端点并通过 HTTP 公开它:

      management.endpoints.web.expose=*
      management.endpoint.shutdown.enabled=true
      

      正如 cmets 中已经指出的,以及在 Actuator HTTP API documentation 中描述的那样,您还需要发出 POST 请求,因此无法在浏览器中访问端点。你可以在命令行上使用类似curl 的东西:

      $ curl -X POST localhost:8080/actuator/shutdown
      

      您可以通过阅读release notes了解更多关于 Spring Boot 2.0 的变化。

      【讨论】:

      • 谢谢!我错过了一个事实,即除了公开端点之外,还必须明确启用它!否则日志中有一个警告(但我没有给予足够的重视,因此无法确定我错过了什么)。
      猜你喜欢
      • 1970-01-01
      • 2017-03-23
      • 2018-06-17
      • 1970-01-01
      • 1970-01-01
      • 2020-05-27
      • 2018-09-07
      • 2018-12-18
      • 1970-01-01
      相关资源
      最近更新 更多