Spring Boot Actuator 更改 /health 的格式

Spring Boot Actuator Change the format of /health

最近我将 spring-boot-starter-actuator 更新到 2.2.2,当我使用 /health 端点时,我得到:

{
    "groups": [],
    "status": {
        "code": "UP",
        "description": ""
    }
}

而不是:

{
    "status": "UP"
}

而且我不知道这是什么原因。任何的想法?或者如何将输出 json 重新格式化为原始格式?不覆盖 HealthIndicator,只重新格式化。

提前致谢。

Spring 执行器 2.2 Health Endpoint JSON 文档说:

The /actuator/health endpoint has changed the resulting JSON format by renaming details to components for the first-level elements. This helps to differentiate the actual details returned by a HealthIndicator from the component indicators that make up composite health.

As a result of the change, the actuator media type has been bumped from application/vnd.spring-boot.actuator.v2+json to application/vnd.spring-boot.actuator.v3+json. If you have tools that need to consume the older format, you can use an HTTP Accept: header with the V2 media type, application/vnd.spring-boot.actuator.v2+json.

此外,如果您想查看与 health 以及什么是 groups 相关的所有文档?如何自定义 health indicator 看看 Current Health Information