为什么我的应用程序中没有启用关闭端点?
Why is the shutdown endpoint not enabled in my application?
我正在尝试在我的 Spring 应用程序中添加关闭端点 actuator/shutdown
,如 this tutorial 中所述,以便我可以使用 [=14= 之类的调用正常关闭应用程序].
我加了
<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
端点?
这可能是因为您使用的 Spring/Actuator 版本,端点在 Spring Boot 2.0 中发生了很大变化,因此您的配置已过时。
接下来试试:
management.endpoints.web.expose=*
management.endpoint.shutdown.enabled=true
或
management.endpoints.web.exposure.include=shutdown
management.endpoint.shutdown.enabled=true
您可以在 release notes 中查看有关 Spring Boot 2.0 更改的更多信息。
看来你用的是yaml,*
在yaml中有特殊含义,必须加引号。
以下应该有效
management:
endpoint:
shutdown:
enabled: true
endpoints:
web:
exposure:
include: "*"
我正在尝试在我的 Spring 应用程序中添加关闭端点 actuator/shutdown
,如 this tutorial 中所述,以便我可以使用 [=14= 之类的调用正常关闭应用程序].
我加了
<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
端点?
这可能是因为您使用的 Spring/Actuator 版本,端点在 Spring Boot 2.0 中发生了很大变化,因此您的配置已过时。 接下来试试:
management.endpoints.web.expose=*
management.endpoint.shutdown.enabled=true
或
management.endpoints.web.exposure.include=shutdown
management.endpoint.shutdown.enabled=true
您可以在 release notes 中查看有关 Spring Boot 2.0 更改的更多信息。
看来你用的是yaml,*
在yaml中有特殊含义,必须加引号。
以下应该有效
management:
endpoint:
shutdown:
enabled: true
endpoints:
web:
exposure:
include: "*"