java - 为什么我的应用程序中未启用关闭端点?
问题描述
我正在尝试按照本教程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
端点出现,我需要更改什么?
解决方案
看来您使用的是 yaml,*
在 yaml 中有特殊含义,必须引用。
以下应该工作
management:
endpoint:
shutdown:
enabled: true
endpoints:
web:
exposure:
include: "*"
推荐阅读
- xml - 甲骨文 XML 版本
- swift - 更改图像形状后,SwiftUI 无法编译
- c - 使用 C 以并行方式读取二维数组
- python - AttributeError:“成员”对象没有属性“public_flags”
- python - 使用“键盘”在失焦时打开新窗口
- javascript - 在哪里定义数据表以及如何添加/更新行/单元格值?
- c++ - 说 C++ 标准中语法选项的表示中没有隐含的顺序是否正确?
- javascript - 如何显示存储在 javascript 对象中的格式化 html 代码
- python-3.x - 有没有办法用 TypeError 异常缩短这个 json 代码?
- windows - 如果您在 C:/ 驱动器中运行 findstr 命令,它会执行多深?