• Maven依赖解决


    记一次Maven依赖冲突解决

    zookeeper为例

    一、问题描述

    1. 当下载zookeeper的2.2.6.RELEASE时,报错
      Could not find artifact org.springframework.cloud:spring-cloud-starter-zookeeper-discovery:pom:2.2.6.RELEASE in central (https://repo.maven.apache.org/maven2)
      在这里插入图片描述
    • 说明在maven仓库中找不到2.2.6.RELEASE这个版本,那么现在我们就应该去看是不是中央仓库配置出了问题,最快验证办法就是下载其他依赖,发现可以正常下载,说明中央仓库配置没出问题。在这里,顺便推荐下面的中央仓库alibaba镜像配置
      <mirrors>
        <mirror>
         <id>aliyunmavenid>
         <mirrorOf>centralmirrorOf>
         <name>阿里云公共仓库name>
         <url>https://maven.aliyun.com/repository/centralurl>
        mirror>
        <mirror>
          <id>repo1id>
          <mirrorOf>centralmirrorOf>
          <name>central reponame>
          <url>http://repo1.maven.org/maven2/url>
        mirror>
        <mirror>
         <id>aliyunmavenid>
         <mirrorOf>apache snapshotsmirrorOf>
         <name>阿里云阿帕奇仓库name>
         <url>https://maven.aliyun.com/repository/apache-snapshotsurl>
        mirror>
      mirrors>
      <proxies/>
      <activeProfiles/>
      <profiles>
        <profile>  
            <repositories>
               <repository>
                    <id>aliyunmavenid>
                    <name>aliyunmavenname>
                    <url>https://maven.aliyun.com/repository/publicurl>
                    <layout>defaultlayout>
                    <releases>
                            <enabled>trueenabled>
                    releases>
                    <snapshots>
                            <enabled>trueenabled>
                    snapshots>
                repository>
                <repository>
                    <id>MavenCentralid>
                    <url>http://repo1.maven.org/maven2/url>
                repository>
                <repository>
                    <id>aliyunmavenApacheid>
                    <url>https://maven.aliyun.com/repository/apache-snapshotsurl>
                repository>
            repositories>             
         profile>
      profiles>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48

    当ali镜像找不到时,会去maven中央仓库寻找

    1. 检查中央仓库配置无误后,就应该看仓库中是否存在这个依赖
    • 第一步看maven仓库,maven。(看这个比较麻烦)
    • 第二步看ali镜像仓库,ali-mirror
      在这里插入图片描述
      观察发现确实没有2.2.6.RELEASE这个版本,那么我们可以换成2.2.5的版本
      在这里插入图片描述
    1. 上面换成2.2.5之后,又带来了一个新的问题,那就是spring-cloud-starter-zookeeper-discovery这个依赖,spring自带了一个zookeeper的版本,但是这个zookeeper依赖没有下载,所以报错Cannot resolve org.apache.zookeeper:zookeeper:3.5.3-beta。接下来我们有两种办法:
    • 下载zookeeper:3.5.3-beta版本即可
    • 在spring-cloud-starter-zookeeper-discover排除zookeeper:3.5.3-beta,重新导入其他版本的zookeeper

    这里使用第二种办法,版本号已经在父工程中约束

    在这里插入图片描述

    		
                org.springframework.cloud
                spring-cloud-starter-zookeeper-discovery
                
                    
                        org.apache.zookeeper
                        zookeeper
                    
                
            
            
                org.apache.zookeeper
                zookeeper
            
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
  • 相关阅读:
    Kubernetes集群故障排查—节点健康监测
    Abnova丨ACTN4 DNA 探针解决方案
    设计模式——职责链模式
    软考 - 系统架构设计师 - 架构风格例题
    C#开发的OpenRA游戏之雷达地图
    莞中 2022暑假训练题02:平衡树
    Ubuntu Kafka开机自启动服务
    贪心:区间问题
    网络的配置
    封阳台怎么避坑
  • 原文地址:https://blog.csdn.net/Proxbj/article/details/133758132