spring-boot health不显示详细信息(withDetail info) [英] spring-boot health not showing details (withDetail info)

查看:1065
本文介绍了spring-boot health不显示详细信息(withDetail info)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have written a class implementing HealthIndicator, overriding the health-method. I return Health.down().withDetail("SupportServiceStatus", "UP").build();

这应该使我的健康 -endpoint返回:

This should make my health-endpoint return:

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

相反它只返回(健康,没有详细信息):

Instead it just returns (health, without details):

{
    "status":"UP",
}

Javacode(略微简化):

Javacode (somewhat simplified):

@Component
public class ApplicationHealth implements HealthIndicator {

  @Override
  public Health health() {
    return check();
  }

  private Health check() {
    return Health.up().withDetail("SupportServiceStatus", supportServiceStatusCode).build();
  }

}


推荐答案

根据spring-boot docs:

According to spring-boot docs:


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

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

Solution is to set endpoints.health.sensitive to false in application.properties.

application.properties

application.properties

endpoints.health.sensitive=false

For> 1.5.1 application.properties

For >1.5.1 application.properties

management.security.enabled=false 

在Spring Boot 2.0.0.RELEASE(thx rvit34 ):

At Spring Boot 2.0.0.RELEASE (thx rvit34):

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

这篇关于spring-boot health不显示详细信息(withDetail info)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆