Spring Gateway 版本依赖关系

3,749 阅读1分钟

本文经作者授权转载,原文作者:HD Superman,原文链接:Spring Gateway 版本依赖关系

背景

某天后台日志系统报 Spring Gateway 大量错误,其中很多报错如下:

io.netty.channel.AbstractChannel$AnnotatedConnectException: finishConnect(..) failed: Connection refused

由于最近后台系统整体往 JDK11 升级,很多工程都是直接 copy 过去,或者直接新建项目目录进行迁移,初步怀疑是版本问题。

定位到 Spring Gateway 工程上 maven 很多依赖没有标版本,google 查到的大部分错误也提到版本冲突问题。初步怀疑是版本冲突问题,进一步定位。

Spring Gateway 用到了下面几个关键包:

  • spring-boot-starter-parent
  • spring-cloud
  • spring-cloud-starter-gateway
  • spring-cloud-alibaba
  • spring-cloud-starter-alibaba-nacos-config

怀疑相关包依赖冲突,导致 Bug 出现,后来查了相关依赖关系,修改版本号后 Bug 消除。下面总结下相关版本的依赖关系,避免后续项目迁移、升级再次出现类似问题。

Spring Boot 与 Spring Cloud 版本依赖关系

官方信息:start.spring.io/actuator/in… 链接打开为 json 格式没有格式化,可以用 firefox 打开,显示如下图:

Spring Boot 与 Spring Cloud Alibaba 版本依赖关系

组件版本关系

Spring Cloud Alibaba VersionSentinel VersionNacos VersionRocketMQ VersionDubbo VersionSeata Version
2.2.1.RELEASE or 2.1.2.RELEASE or 2.0.2.RELEASE1.7.11.2.14.4.02.7.61.2.0
2.2.0.RELEASE1.7.11.1.44.4.02.7.4.11.0.0
2.1.1.RELEASE or 2.0.1.RELEASE or 1.5.1.RELEASE1.7.01.1.44.4.02.7.30.9.0
2.1.0.RELEASE or 2.0.0.RELEASE or 1.5.0.RELEASE1.6.31.1.14.4.02.7.30.7.1

毕业版本依赖关系(推荐使用)

Spring Cloud VersionSpring Cloud Alibaba VersionSpring Boot Version
Spring Cloud Hoxton.SR32.2.1.RELEASE2.2.5.RELEASE
Spring Cloud Hoxton.RELEASE2.2.0.RELEASE2.2.X.RELEASE
Spring Cloud Greenwich2.1.2.RELEASE2.1.X.RELEASE
Spring Cloud Finchley2.0.2.RELEASE2.0.X.RELEASE
Spring Cloud Edgware1.5.1.RELEASE(停止维护,建议升级)1.5.X.RELEASE

以上述 Bug 为例子,项目主要用的Spring Boot 版本为:2.2.5.RELEASE

  • 对应查到 Spring Cloud 使用的版本应该为: Hoxton.SR3 系列版本
  • 对应查到 Spring Cloud Alibaba 应该使用使用:2.2.1.RELEASE
  • 对应查到 Nacos 应该使用 1.2.1 版本

参考资料

  1. Spring Cloud Alibaba 版本说明
  2. Spring version