Spring Boot中Actuator健康端点未显示Circuit Breaker组件排查
问题:Actuator健康端点不显示Resilience4j断路器信息,配置缺失什么?
我已经在application.yml中配置了Actuator与Resilience4j,pom.xml也引入了相关依赖,但访问/actuator/health时看不到Circuit Breaker的配置信息,请问哪里配置错了?
我的application.yml配置:
management: endpoint: health: show-details: always circuitbreakers: enabled: true web: # 冗余无效配置 endpoints: web: exposure: include: health resilience4j: circuitbreaker: instances: ratingHotelBreaker: register-health-indicator: true event-consumer-buffer-size: 10 failure-rate-threshold: 50 minimum-number-of-calls: 5 automatic-transition-from-open-to-half-open-enabled: true wait-duration-in-open-state: 6s permitted-number-of-calls-in-half-open-state: 3 sliding-window-size: 10 sliding-window-type: count_based
pom.xml关键依赖配置:
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-aop</artifactId> </dependency> <!-- 适配Spring Boot 2.x的依赖,与当前Spring Boot 3.x不兼容 --> <dependency> <groupId>io.github.resilience4j</groupId> <artifactId>resilience4j-spring-boot2</artifactId> </dependency>
核心问题及修复方案
1. 依赖版本不兼容
你使用的Spring Boot版本是3.0.1,但引入的resilience4j-spring-boot2是专门适配Spring Boot 2.x的依赖,版本不匹配会导致Resilience4j的自动配置逻辑失效。
修复:
替换为Spring Boot 3.x对应的Resilience4j依赖:
<dependency> <groupId>io.github.resilience4j</groupId> <artifactId>resilience4j-spring-boot3</artifactId> <!-- 建议指定兼容版本,比如2.0.2或更高,可根据Spring Cloud版本匹配 --> </dependency>
2. Actuator未启用断路器健康指示器
你的配置中缺少启用断路器健康检查的关键开关,同时存在冗余的web:节点导致配置结构错误。
修复:
修正application.yml的management配置:
management: health: circuitbreakers: enabled: true # 开启健康端点中的断路器状态展示 endpoint: health: show-details: always circuitbreakers: enabled: true endpoints: web: exposure: include: health # 若需单独访问断路器端点,可添加circuitbreakers
3. 断路器实例未被实际调用
Resilience4j的健康指示器只会展示被实际触发过的断路器实例。如果你的ratingHotelBreaker还没有被业务方法使用(比如没有给目标方法添加@CircuitBreaker(name = "ratingHotelBreaker")注解),它不会出现在健康端点的返回结果中。
验证:
修复上述配置后,重启服务,调用一次带有该断路器注解的接口,再访问/actuator/health,就能看到包含断路器状态的健康信息。
内容的提问来源于stack exchange,提问作者Pratik Panchal
相关产品推荐
相关产品推荐

