首页 > 解决方案 > 为什么我的应用程序中未启用关闭端点?

问题描述

我正在尝试按照本教程actuator/shutdown中的说明在我的 Spring 应用程序中添加一个关闭端点,以便我可以使用类似.curl -X POST localhost:8080/actuator/shutdown

我添加了

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

对我pom.xml

management:
  endpoints.web.exposure.include: *
  endpoint.shutdown.enabled: true
endpoints.shutdown.enabled: true
management.endpoint.shutdown.enabled: true

src/main/resources/application.yaml.

但是当我运行时curl -X POST localhost:8080/actuator/shutdown,我得到以下响应:

{"timestamp":"2020-04-10T10:49:36.758+0000","status":404,"error":"Not Found",
"message":"No message available","path":"/actuator/shutdown"}

我没有在以下位置看到关闭端点http://localhost:8080/actuator

执行器端点的屏幕截图

我究竟做错了什么?为了使actuator/shutdown端点出现,我需要更改什么?

标签: javaspringspring-boot-actuator

解决方案


看来您使用的是 yaml,*在 yaml 中有特殊含义,必须引用。

以下应该工作

management:
  endpoint:
    shutdown:
      enabled: true
  endpoints:
    web:
      exposure:
        include: "*"

推荐阅读