2015-10-06 57 views
6

我写一个类实现HealthIndicator,覆盖医疗方法。我回到Health.down().withDetail("SupportServiceStatus", "UP").build();弹簧引导健康没有显示细节(withDetail资讯)

这应该使我health -endpoint回报:

{ 
    "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(); 
    } 

} 

回答

9

根据春季启动文档:

。 。 。默认情况下,只有健康状态通过未经身份验证的HTTP连接公开。如果您对完整的健康信息感到满意,您可以将endpoints.health.sensitive设置为false

解决办法是设置endpoints.health.sensitivefalseapplication.properties

application.properties

endpoints.health.sensitive=false 

对于> 1.5.1 application.properties

management.security.enabled=false 
+0

没有弹簧启动的新版本 – cahen

+0

更新的答案。需要管理标志在1.4.2-RELEASE – olahell

+0

对于> 1.4.1我觉得工作1.5.1 – Jontia

5

设置 'endpoints.health.sensitive' 没有什么区别......不得不设置:

management: 
    security: 
     enabled: false 
+1

我想,这不仅是因为1.4.1.RELEASE和1.5之间的某个时候需要.1.RELEASE(我刚升级并且必须这样做) – James

1

在Spring Boot 2.0.0.RELEASE:

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