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

时间:2015-10-06 13:25:12

标签: java spring spring-boot

我编写了一个实现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();
  }

}

7 个答案:

答案 0 :(得分:32)

根据spring-boot docs:

  

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

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

application.properties

endpoints.health.sensitive=false

对于> 1.5.1 application.properties

management.security.enabled=false 

在Spring Boot 2.0.0.RELEASE(thx @rvit34@nisarg-panchal):

management:
  endpoint:
    health:
      show-details: "ALWAYS"
  endpoints:
    web:
      exposure:
        include: *

management.endpoints.web.exposure.include=*公开所有端点,如果这是您想要的。

目前的文档可以在这里找到:https://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-endpoints.html

答案 1 :(得分:8)

在Spring Boot 2.0.0.RELEASE:

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

答案 2 :(得分:7)

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

management:
    security:
        enabled: false

答案 3 :(得分:5)

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

对于Springboot 2.x.x.RELEASE,

在以下使用application.properties,

2480 x 3508px

在下面将其用于applicaton.yml,

function mmToPt (mm) { return mm * 2.83465; } function cmToPt (cm) { return cm * 28.3465; } function inchToPt (inch) { return inch * 72; } const units = [ 1, 2, 3, 5, 10, 15, 20, 25, 50, 100, 150, 250, 500, 1000 ]; function convert (unit) { let name; let converter; switch (unit) { case 'mm': name = 'millimeters'; converter = mmToPt; break; case 'cm': name = 'centimeters'; converter = cmToPt; break; case 'inch': name = 'inches'; converter = inchToPt; break; } console.log(`Convert ${name} to points:`); units.forEach(u => { let converted = converter(u).toFixed(2); // get rid of unneeded .00 decimals if (+converted === parseInt(converted, 10)) { converted = +converted; } console.log(`${u}${unit} is ${converted}pt, so in doc.text(${converted}, ${converted}, 'Message')`); }); console.log('--------------------------------------------'); } convert('mm'); convert('cm'); convert('inch');

答案 4 :(得分:2)

对于Spring boot 2.X,我在application.properties文件中具有以下详细信息:

<span class="subtitleMain" id="totalMachines">0</span>

答案 5 :(得分:0)

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

management.security.enabled=false

答案 6 :(得分:0)

需要添加

management.endpoint.health.show-details=always

到Application.properties