又是美好的一天呀~
个人博客地址: huanghong.top
背景
项目中引入spring-cloud-starter-zookeeper-discovery依赖将zookeeper作为注册中心,但关联SpringCloud版本依赖中指定zookeeper版本为3.6.0,与客户zookeeper服务端(3.4.10)版本不适配,项目启动会直接抛出KeeperErrorCode = Unimplemented for /services/application/5227a8b6-acf7-4550-8b0f-0a6eca7bd397
异常,经过测试及查询确定该异常由zookeeper客户端与服务端版本不适配导致。
依赖版本说明
springBootVersion = "2.6.6"
springCloudVersion = "2021.0.1"
解决方案
- 在引入的spring-cloud-starter-zookeeper-discovery中排除zookeeper-3.6.0、curator-x-discovery、curator-framework、curator-client、curator-recipes
- 重新引入zookeeper-3.4.10、curator-x-discovery-4.2.0、curator-framework-4.2.0、curator-client-4.2.0、curator-recipes-4.2.0
gradle项目
//zookeeper
api ("org.springframework.cloud:spring-cloud-starter-zookeeper-discovery"){
exclude module: 'zookeeper'
exclude module: 'curator-x-discovery'
exclude module: 'curator-framework'
exclude module: 'curator-client'
exclude module: 'curator-recipes'
}
//zookeeper降级为3.4.10
api "org.apache.zookeeper:zookeeper:3.4.10"
api "org.apache.curator:curator-x-discovery:4.2.0"
api "org.apache.curator:curator-framework:4.2.0"
api "org.apache.curator:curator-client:4.2.0"
api "org.apache.curator:curator-recipes:4.2.0"
maven项目
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-zookeeper-discovery</artifactId>