spring boot升级至2.7.5后,/actuator/health接口默认返回{"status":{"code":"down"}},即使服务正常运行——这是因新版actuator默认隐藏健康详情且启用严格组检查所致,需通过配置开启详细信息展示并合理设置健康组策略。
在 Spring Boot 2.6+(包括 2.7.5)版本中,Actuator 的 /actuator/health 端点行为发生重要变更:
✅ 正确解决方案包含两个关键配置(推荐组合使用):
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
⚠️ 注意事项:
? 总结:"DOWN" 并非服务异常,而是 Actuator 新版安全策略下的默认表现。通过 show-details=always 解锁详情,并辅以合理的健康组配置,即可恢复准确、可诊断的健康状态响应。