Spring Boot监控系统故障处理
最近在项目中遇到Spring Boot Actuator监控系统异常问题,记录一下踩坑过程。
问题现象
应用启动后,/actuator/health接口返回500错误,监控数据无法获取。通过日志发现如下异常:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'healthIndicatorRegistry'
复现步骤
- 创建Spring Boot项目,添加actuator依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
- 配置application.yml
management:
endpoints:
web:
exposure:
include: health,info,metrics
endpoint:
health:
show-details: always
解决方案
问题出在健康检查配置不当。需要明确指定健康检查的组件:
management:
endpoints:
web:
exposure:
include: health,info,metrics
endpoint:
health:
show-details: always
probes:
enabled: true
health:
defaults:
enabled: true
关键点提醒
- 确保配置文件中正确声明了监控端点
- 避免使用过时的配置方式
- 生产环境建议限制暴露的端点
通过以上调整,监控系统恢复正常。

讨论