spring-boot health不显示详细信息(withDetail info)

我编写了一个实现HealthIndicator的类,重写了health-method。 我返回Health.down().withDetail("SupportServiceStatus", "UP").build();

这应该让我的health终点回归:

 { "status":"UP", "applicationHealth": { "status":"UP" } } 

相反,它只返回(健康,没有细节):

 { "status":"UP", } 

Javacode(稍微简化):

 @Component public class ApplicationHealth implements HealthIndicator { @Override public Health health() { return check(); } private Health check() { return Health.up().withDetail("SupportServiceStatus", supportServiceStatusCode).build(); } } 

根据spring-boot文档:

。 。 。 默认情况下,仅通过未经身份validation的HTTP连接公开运行状况。 如果您希望始终公开完整的健康信息,则可以将endpoints.health.sensitive设置为false

解决方案是在application.properties中将endpoints.health.sensitive设置为false

application.properties

 endpoints.health.sensitive=false 

对于> 1.5.1 application.properties

 management.security.enabled=false 

在Spring Boot 2.0.0.RELEASE(thx rvit34 ):

 management: endpoint: health: show-details: "ALWAYS" 

在Spring Boot 2.0.0.RELEASE:

 management: endpoint: health: show-details: "ALWAYS" 

设置’endpoints.health.sensitive’没有区别……必须设置:

 management: security: enabled: false 

谢谢@ rvit34和@Ninja Code Monkey的工作。

对于Springboot 2.xxRELEASE,

以下用于application.properties,

management.endpoint.health.show-details=ALWAYS

使用以下appaton.yml,

management: endpoint: health: show-details: "ALWAYS"

我有同样的问题,在Spring Boot 1.5.9版本上我必须设置

 management.security.enabled=false