背景:
搭建 nacos 注册中心时,SpringCloud 版本和 Spring Boot 版本不一致,nacos 版本使用过低导致 nacos 无法注册。
分析:
Nacos1.0.0以上版本是支持 Spring Boot 2.1.x版本,当然也向下兼容。
重点要说的是如何知道 Spring Cloud 跟 Spring Boot之间的兼容关系
当然是通过官网 Spring Cloud官网地址,红圈便是当前最新的版本,Greenwich
其次就是将这个页面拉到底,看到一个版本兼容的表格
Release Train | Boot Version | Spring Cloud Alibaba |
Greenwich | 2.1.x | 0.2.2(还没有RELEASE) |
Finchley | 2.0.x | 0.2.1 |
Edgware | 1.5.x | 0.1.1 |
Dalston | 1.5.x | 0.1.1 |
如何解决?
两种解决方案, 方案二必须选择nacos1.0.0
1. 将Spring Boot 版本使用2.0.x ,Spring Cloud 版本使用 Finchley
2. 将Spring Boot 版本使用2.1.x ,Spring Cloud 版本使用 Greenwich
由于 Spring Cloud Alibaba 0.2.1.RELEASE使用的是nacos-client-0.6的,需要切换
<dependency>
<groupId>com.alibaba.nacos</groupId>
<artifactId>nacos-client</artifactId>
<version>1.0.0-RC2</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
<version>0.2.1.RELEASE</version>
<exclusions>
<exclusion>
<groupId>com.alibaba.nacos</groupId>
<artifactId>nacos-client</artifactId>
</exclusion>
</exclusions>
</dependency>
最后,版本一定要注意!!!
Please enjoy the pain which is unable to avoid.
请享受无法回避的痛苦。