ola*_*ell 20 java spring spring-boot
我编写了一个实现HealthIndicator的类,重写了health-method.我回来Health.down().withDetail("SupportServiceStatus", "UP").build();
这应该让我的health-endpoint返回:
{
"status":"UP",
"applicationHealth": {
"status":"UP"
}
}
Run Code Online (Sandbox Code Playgroud)
相反它只返回(健康,没有细节):
{
"status":"UP",
}
Run Code Online (Sandbox Code Playgroud)
Javacode(略微简化):
@Component
public class ApplicationHealth implements HealthIndicator {
@Override
public Health health() {
return check();
}
private Health check() {
return Health.up().withDetail("SupportServiceStatus", supportServiceStatusCode).build();
}
}
Run Code Online (Sandbox Code Playgroud)
ola*_*ell 38
根据spring-boot文档:
...默认情况下,仅通过未经身份验证的HTTP连接公开健康状况.如果您对完整的健康信息感到满意,那么您可以将其设置
endpoints.health.sensitive为false.
解决办法是设置endpoints.health.sensitive到false在application.properties.
application.properties
endpoints.health.sensitive=false
Run Code Online (Sandbox Code Playgroud)
对于> 1.5.1 application.properties
management.security.enabled=false
Run Code Online (Sandbox Code Playgroud)
在Spring Boot 2.0.0.RELEASE(thx @rvit34):
management:
endpoint:
health:
show-details: "ALWAYS"
endpoints:
web:
exposure:
include: *
Run Code Online (Sandbox Code Playgroud)
rvi*_*t34 11
在Spring Boot 2.0.0.RELEASE:
management:
endpoint:
health:
show-details: "ALWAYS"
Run Code Online (Sandbox Code Playgroud)
小智 7
设置'endpoints.health.sensitive'没有区别......必须设置:
management:
security:
enabled: false
Run Code Online (Sandbox Code Playgroud)
小智 5
感谢@ rvit34和@Ninja Code Monkey的工作。
对于Springboot 2.xxRELEASE,
将以下用于application.properties,
management.endpoint.health.show-details=ALWAYS
在下面用于applicaton.yml,
management:
endpoint:
health:
show-details: "ALWAYS"
| 归档时间: |
|
| 查看次数: |
14705 次 |
| 最近记录: |