You need to enable JavaScript to run this app. 运行Spring项目时出现reactor.netty ConnectionProvider$Builder类路径错误如何解决
优惠活动
大模型
产品
解决方案
定价
更多

运行Spring项目时出现reactor.netty ConnectionProvider$Builder类路径错误如何解决

问题成因
  • 该错误属于典型的依赖版本不兼容导致的NoSuchMethodError:你当前加载的reactor-netty 0.9.12.RELEASE版本中,reactor.netty.resources.ConnectionProvider$Builder类的evictInBackground方法签名,与Spring Cloud Gateway调用该方法时预期的签名不匹配。0.9.12.RELEASE版本的该方法返回值为Builder本身,而你使用的Spring Cloud Gateway版本要求该方法返回ConnectionProvider$ConnectionPoolSpec类型,调用时无法找到匹配的方法导致启动失败。
  • 触发原因是项目类路径下存在多版本的reactor-netty依赖,Maven依赖仲裁机制优先加载了低版本的0.9.12.RELEASE,无法满足Spring Cloud Gateway的版本要求。
处理方案
  • 第一步:核对Spring Boot、Spring Cloud的版本匹配关系,确保Spring Cloud Gateway的版本与Spring Cloud父版本完全一致,不要单独引入跨版本的Gateway依赖。
  • 第二步:排查reactor-netty的依赖冲突,执行Maven命令mvn dependency:tree -Dincludes=io.projectreactor.netty:reactor-netty,定位所有引入reactor-netty的依赖节点,对引入了低版本reactor-netty的依赖添加排除规则:
<dependency>
    <groupId>冲突依赖的groupId</groupId>
    <artifactId>冲突依赖的artifactId</artifactId>
    <exclusions>
        <exclusion>
            <groupId>io.projectreactor.netty</groupId>
            <artifactId>reactor-netty</artifactId>
        </exclusion>
    </exclusions>
</dependency>
  • 第三步:手动声明符合版本要求的reactor-netty依赖,确保版本与Spring Cloud版本兼容:
    • Spring Cloud Hoxton版本:使用reactor-netty 0.9.25.RELEASE及以上的0.9.x分支版本
    • Spring Cloud 2020.0.x及以上版本:使用reactor-netty 1.0.x及以上分支版本
  • 第四步:清理本地Maven缓存后重新构建,执行命令mvn clean install -U强制刷新依赖,避免本地缓存的旧jar包干扰。

内容的提问来源于stack exchange,提问作者samarth khandelwal

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.10.18 05:24:07