记一次学习SpringCloud将zk作为注册中心的bug

记一次学习SpringCloud将zk作为注册中心的bug

问题描述:

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-zookeeper-discovery</artifactId>
</dependency>
  • 版本信息

    spring-cloud-starter-zookeeper-discovery:2.2.0.RELEASE

    而安装的windows,zk版本为:3.4.10

  • 启动项目后

    image-20200825094824672

解决方案

1. IDEA右侧的Dependencies

初步判定是因为客户端使用的版本为3.5.3-beta,太高了,这个再IDEA也可以看出依赖情况:

image-20200825095137949

2.通过mvn dependency:tree

但是太费劲了,我们可以在cloud2020根目录用mvn dependency:tree>tree.txt,执行后发现

image-20200825095647199

这里说下我们项目结构是这样的:

image-20200825095449555

cloud-api-commons是基础module,其他module依赖它

报的错是找不到cloud-api-commons,细看下它的仓库地址是image-20200825095606768

这个地址不在项目的settings文件里啊,怎么回事?

原来执行mvn dependency:tree>tree.txt,用的settings文件是系统默认的maven的settings文件,这里我们项目自定义了,所以要跟项目一致

执行

mvn -s C:Usersmdl.m2settings-qy.xml dependency:tree>tree.txt

image-20200825095954684

3.通过IDEA旗舰版的Diagrams

image-20200825100900599

image-20200825102249780

ctrl + f :

image-20200825102324802

image-20200825102408828

4. 改用3.4.10的zk

image-20200825100106947

每一步脚印都要扎得深一点!
原文地址:https://www.cnblogs.com/bloodthirsty/p/13558279.html