Spring Boot监控系统故障处理

HotStar +0/-0 0 0 正常 2025-12-24T07:01:19 Spring Boot · 监控

Spring Boot监控系统故障处理

最近在项目中遇到Spring Boot Actuator监控系统异常问题,记录一下踩坑过程。

问题现象

应用启动后,/actuator/health接口返回500错误,监控数据无法获取。通过日志发现如下异常:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'healthIndicatorRegistry'

复现步骤

  1. 创建Spring Boot项目,添加actuator依赖
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
  1. 配置application.yml
management:
  endpoints:
    web:
      exposure:
        include: health,info,metrics
  endpoint:
    health:
      show-details: always
  1. 启动应用,访问http://localhost:8080/actuator/health

解决方案

问题出在健康检查配置不当。需要明确指定健康检查的组件:

management:
  endpoints:
    web:
      exposure:
        include: health,info,metrics
  endpoint:
    health:
      show-details: always
      probes:
        enabled: true
  health:
    defaults:
      enabled: true

关键点提醒

  • 确保配置文件中正确声明了监控端点
  • 避免使用过时的配置方式
  • 生产环境建议限制暴露的端点

通过以上调整,监控系统恢复正常。

推广
广告位招租

讨论

0/2000
SpicySteve
SpicySteve · 2026-01-08T10:24:58
这问题太典型了,Spring Boot Actuator的健康检查机制在新版本里变化很大,很多开发者还在用旧配置,结果直接导致Bean创建失败。建议直接看官方文档,别自己瞎试配置项。
秋天的童话
秋天的童话 · 2026-01-08T10:24:58
生产环境暴露所有监控端点简直是自寻死路,虽然配置文件里写了show-details: always,但没限制访问权限,这不就是给攻击者送人头吗?应该配合JWT或IP白名单管控。