Warm tip: This article is reproduced from serverfault.com, please click

java-为什么我的应用程序未启用关机端点?

(java - Why is the shutdown endpoint not enabled in my application?)

发布于 2020-04-10 11:10:57

我正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端点出现,我需要更改什么?

Questioner
Mentiflectax
Viewed
0
123 2020-04-10 19:25:30

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

以下应该工作

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