java - springboot 2.3.0 actuator liveness/readiness check 返回错误响应
问题描述
我正在尝试使用 spring boot 2.3.0 在本地测试活跃度/准备情况。当我公开 API 时,它确实返回正确的状态,但不是正确的响应。基于https://spring.io/blog/2020/03/25/liveness-and-readiness-probes-with-spring-boot,当我公开时,我期待组件、磁盘空间等/actuator/health
,但我得到:
{
"status": "UP",
"groups": [
"liveness",
"readiness"
]
}
我很确定我的 pom.xml 是正确的,因为它返回了正确的状态。我认为这与配置有关。这是我的本地配置设置(application.properties):
spring.datasource.driverClassName=com.microsoft.sqlserver.jdbc.SQLServerDriver
spring.datasource.url=jdbc:sqlserver://myurl.net;database
spring.datasource.username=username
spring.datasource.password=password
management.health.probes.enabled=true
management.endpoint.health.group.readiness.include=readinessProbe,db
我错过了什么吗?即使我调用 /actuator/health/liveness,我得到的只是
{
"status": "UP"
}
“状态”确实显示了正确的值(UP 或 DOWN),但缺少组件。
解决方案
健康端点公开的信息取决于management.endpoint.health.show-details
和management.endpoint.health.show-components
属性,可以使用以下值之一进行配置never
,when-authorized
, always
。默认值为never
。
因此,如果您将值设置management.endpoint.health.show-components
为always
它应该显示您的期望。
推荐阅读
- css - Material UI:如何使用填充其父宽度的容器使文本溢出可滚动?
- r - 在 xaringan 幻灯片底部添加横幅
- bash - 检查目录字符串中的字符串:Bash 脚本
- html - 编织/渲染 R Markdown 输出:我可以阻止代码在 PDF 输出中显示,但允许在 HTML 输出中折叠代码吗?
- ios - 拍照后如何使用 Flutter 的“image_picker”插件访问原始文件路径?
- javascript - Material-UI:您为 select (name="reward") 组件提供了超出范围的值`[object Object]`
- html - 当我调整浏览器的大小而不是在移动设备上时,媒体查询工作正常
- swiftui - SwiftUI - 带有绑定的@State 属性结构不会导致重绘
- javascript - 如何在不更新先前渲染的情况下渲染 onClick 事件的不同数据?
- c++ - 为什么 C++“使用 XXX = type”类型别名需要“typename”?