• 【 构建maven工程时,配置了阿里云的前提下,依旧使用中央仓库下载依赖导致失败的问题!】


    构建maven工程时,配置了阿里云的前提下,依旧使用中央仓库下载依赖导致失败的问题!!!

    错误提示信息:

    Cannot download ZIP distribution from https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.5.4/apache-maven-3.5.4-bin.zip. Please check distributionUrl The Maven wrapper was disabled. The Maven bundled version will be used instead.

    问题原因:

    由于在构建项目时,我们在setting中已经配置了阿里云镜像,但是下载依赖还是会遵从super pom(所有自定义pom.xml都是继承自super pom),因此,当maven项目需要下载一些metadata、pom、jar的时候,会优先去中央仓库下载,导致内网用户各种报错!

    问题解决方法

    1、在maven的setting.xml文件的中添加仓库地址,如下:

    <mirror>
                <id>alimavenid>
                <mirrorOf>centralmirrorOf>
                <name>aliyun mavenname>
                <url>http://maven.aliyun.com/nexus/content/repositories/central/url>
            mirror>
            <mirror>
                <id>alimavenid>
                <name>aliyun mavenname>
                <url>http://maven.aliyun.com/nexus/content/groups/public/url>
                <mirrorOf>centralmirrorOf>
            mirror>
            <mirror>
                <id>centralid>
                <name>Maven Repository Switchboardname>
                <url>http://repo1.maven.org/maven2/url>
                <mirrorOf>centralmirrorOf>
            mirror>
            <mirror>
                <id>repo2id>
                <mirrorOf>centralmirrorOf>
                <name>Human Readable Name for this Mirror.name>
                <url>http://repo2.maven.org/maven2/url>
            mirror>
            <mirror>
                <id>ibiblioid>
                <mirrorOf>centralmirrorOf>
                <name>Human Readable Name for this Mirror.name>
                <url>http://mirrors.ibiblio.org/pub/mirrors/maven2/url>
            mirror>
            <mirror>
                <id>jboss-public-repository-groupid>
                <mirrorOf>centralmirrorOf>
                <name>JBoss Public Repository Groupname>
                <url>http://repository.jboss.org/nexus/content/groups/publicurl>
            mirror>
            <mirror>
                <id>google-maven-centralid>
                <name>Google Maven Centralname>
                <url>https://maven-central.storage.googleapis.com
                url>
                <mirrorOf>centralmirrorOf>
            mirror>
            
            <mirror>
                <id>maven.net.cnid>
                <name>oneof the central mirrors in chinaname>
                <url>http://maven.net.cn/content/groups/public/url>
                <mirrorOf>centralmirrorOf>
            mirror>
    
    
    • 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
    • 49
    • 50
    • 51

    2、在idea中设置好maven的setting.xml和仓库路径(可以看idea创建maven项目这篇文章中设置项目创建时默认maven配置)

    在这里插入图片描述

    3、在pom.xml中添加阿里云的镜像(注意这个镜像一定要和setting.xml中的镜像一样)

    <repositories>
    		<repository>
    			<id>nexus-aliyunid>
    			<name>nexus-aliyunname>
    			<url>http://maven.aliyun.com/nexus/content/groups/public/url>
    			<releases>
    				<enabled>trueenabled>
    			releases>
    			<snapshots>
    				<enabled>falseenabled>
    			snapshots>
    		repository>
    	repositories>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13

    4、重新加载maven就可以成功构建了!

  • 相关阅读:
    C语言 union 共用体,IIC通信,24C02存储数据
    Hadoop编程——第三章:(2)Linux文件系统基础知识
    【在线编程-Python篇】Python入门 04 列表(上)
    postman的使用
    深入理解 Docker 核心原理:Namespace、Cgroups 和 Rootfs
    Exoplayer异常:4003, MediaCodecAudioRenderer error,format_supported=YES
    git如何手动解决冲突文件
    Cy3-PEG-SH,Cy3-聚乙二醇-巯基/硫醇,Thiol/SH-PEG-Cy3
    SQL 杂谈 1
    C++获取变量的类型和名称
  • 原文地址:https://blog.csdn.net/qq_62124267/article/details/133652855