You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

SpringBoot 2.5.4集成Hystrix启动报BeanCreationException错误如何解决?

问题原因

该报错由Spring Boot与Spring Cloud依赖版本不兼容导致,你使用的Spring Boot 2.5.4与Hystrix 2.2.x依赖对应的Spring Cloud版本适配范围不符,导致配置类初始化失败。

解决方案

方案1:调整Spring Boot版本到适配范围(最稳妥)

将pom.xml中parent节点的Spring Boot版本降级到2.3.x版本,该版本与Hystrix 2.2.8.RELEASE完全适配,修改如下:

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.3.12.RELEASE</version>
    <relativePath /> <!-- lookup parent from repository -->
</parent>

修改后重新导入Maven依赖即可解决问题。

方案2:保留Spring Boot 2.5.4版本,添加兼容依赖管理

如果需要保留当前Spring Boot版本,可通过添加统一依赖管理解决版本冲突:

  1. 在pom.xml的properties节点中添加Spring Cloud版本配置:
<properties>
    <java.version>11</java.version>
    <spring-cloud.version>2020.0.3</spring-cloud.version>
</properties>
  1. 在dependencies节点前添加dependencyManagement节点,统一管理依赖版本:
<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-dependencies</artifactId>
            <version>${spring-cloud.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-netflix-dependencies</artifactId>
            <version>2.2.9.RELEASE</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>
  1. 移除原有hystrix依赖中的version标签,交给依赖管理统一控制版本:
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
</dependency>

修改后清空本地Maven缓存,重新导入依赖即可。

额外注意

  • 确认启动类上@EnableCircuitBreaker注解导入的是org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker包,不要导错。
  • Hystrix已经停止官方维护,长期使用推荐替换为Spring官方推荐的Resilience4j作为熔断器实现。

内容的提问来源于stack exchange,提问作者Ng Sharma

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.05 12:57:01