新装maven建的第一个项目报错,下载失败

问题

错误大概如下,就是无法下载jar包

[ERROR] Plugin org.apache.maven.plugins:maven-clean-plugin:2.5 or one of its dependencies could not be resolve..

尝试了以下方法:

  • 删除这个目录下的C:\Users\Administrator\.m2\repository(你自己的目录)所有文件,没用

  • setting.xml里面换成阿里源,没用

  • 直接在pom.xml加上阿里源,没用

<repositories>
    <repository>
        <id>aliyun</id>
        <name>aliyun</name>
        <url>https://maven.aliyun.com/repository/central/</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </repository>
</repositories>

解决

最后,在这里找到了解决办法

1.首先要知道,IDEA是自带maven的,这里不用它自带,改成我们自己的,首先要去maven官网下载,然后配置环境变量,然后再IDEA里面修改一下配置,如下图,修改红框中的地方,改成自己的maven路径

image.png

2.然后修改一下setting.xml里面的镜像,方便后面下的更快

<mirrors>
    <mirror>
        <id>alimaven</id>
        <name>aliyun maven</name>
        <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
        <mirrorOf>central</mirrorOf>
    </mirror>
    <mirror>
        <id>central</id>
        <name>Maven Repository Switchboard</name>
        <url>http://repo1.maven.org/maven2/</url>
        <mirrorOf>central</mirrorOf>
    </mirror>
    <mirror>
        <id>repo2</id>
        <mirrorOf>central</mirrorOf>
        <name>Human Readable Name for this Mirror.</name>
        <url>http://repo2.maven.org/maven2/</url>
    </mirror>
    <mirror>
        <id>ibiblio</id>
        <mirrorOf>central</mirrorOf>
        <name>Human Readable Name for this Mirror.</name>
        <url>http://mirrors.ibiblio.org/pub/mirrors/maven2/</url>
    </mirror>
    <mirror>
        <id>jboss-public-repository-group</id>
        <mirrorOf>central</mirrorOf>
        <name>JBoss Public Repository Group</name>
        <url>http://repository.jboss.org/nexus/content/groups/public</url>
    </mirror>
    <!-- 中央仓库在中国的镜像 -->
    <mirror>
        <id>maven.net.cn</id>
        <name>oneof the central mirrors in china</name>
        <url>http://maven.net.cn/content/groups/public/</url>
        <mirrorOf>central</mirrorOf>
    </mirror>
</mirrors>

3.最关键的一步,之前下载失败问题都出在这里,看图操作

image.png

如上图所示进入Maven->Runner 然后将下面内容复制粘贴到VM Options当中保存即可。

-Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true -Dmaven.wagon.http.ssl.ignore.validity.dates=true
posted @ 2020-05-13 15:09  harrylyx  阅读(382)  评论(2编辑  收藏  举报