
spring boot升级至2.7.5后,/actuator/health接口默认返回{"status":{"code":"down"}},即使服务正常运行——这是因新版actuator默认隐藏健康详情且启用严格组检查所致,需通过配置开启详细信息展示并合理设置健康组策略。
在 Spring Boot 2.6+(包括 2.7.5)版本中,Actuator 的 /actuator/health 端点行为发生重要变更:
- 默认 show-details 级别为 never,导致健康检查结果被简化为 "DOWN"(即使所有组件实际健康);
- 同时,默认启用了 Health Groups 机制,若未显式配置 groups,部分实现(尤其是与旧版 Springfox 兼容场景)可能因健康指示器分组缺失或校验失败而误判整体状态为 DOWN。
✅ 正确解决方案包含两个关键配置(推荐组合使用):
1. 显式启用健康详情展示(必配)
在 application.properties 中添加:
management.endpoint.health.show-details=always
或在 application.yml 中:
management:
endpoint:
health:
show-details: always2. 明确配置健康组(推荐,尤其当存在自定义健康检查器时)
避免因默认组(如 liveness/readiness)未就绪导致整体 DOWN,可显式声明基础组:
management.endpoint.health.group.liveness.include=ping,discoveryComposite management.endpoint.health.group.readiness.include=ping,discoveryComposite,serviceHealth
或直接使用兼容性更强的 legacy 组(Spring Boot 2.7+ 支持):
management.endpoint.health.group.legacy.include=*
并在主配置中激活:
management.endpoints.web.exposure.include=health,info,metrics,loggers management.endpoint.health.probes.enabled=true
⚠️ 注意事项:
- show-details=always 仅建议在受信内网环境使用;生产环境推荐设为 when_authorized 并配合 Spring Security 鉴权;
- 若项目仍集成 Springfox(非 Springdoc OpenAPI),需确保其健康指示器已正确注册——可添加 @Bean 显式暴露 SpringFoxHealthIndicator(如有);
- 执行 curl http://localhost:8080/actuator/health 后,应返回结构化 JSON,包含各组件(如 diskSpace, ping, db)的具体状态,而非空 DOWN。
? 总结:"DOWN" 并非服务异常,而是 Actuator 新版安全策略下的默认表现。通过 show-details=always 解锁详情,并辅以合理的健康组配置,即可恢复准确、可诊断的健康状态响应。










