略微加速

略速 - 互联网笔记

Maven报错:Downloading from central: https://repo.maven.apache.org/maven2/

2021-12-31 leiting (1666阅读)

标签 JAVA

今天用Maven跑项目时,遇到这样的问题:

Downloading from central: https://repo.maven.apache.org/maven2/...

 

原因:

所有自定义pom.xml都是继承自super pom,spuper pom中有如下内容:

<repositories>
    <repository>
      <id>central</id>
      <name>Central Repository</name>
      <url>http://repo.maven.apache.org/maven2</url>
      <layout>default</layout>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
    </repository>
  </repositories>
 
  <pluginRepositories>
    <pluginRepository>
      <id>central</id>
      <name>Central Repository</name>
      <url>http://repo.maven.apache.org/maven2</url>
      <layout>default</layout>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
      <releases>
        <updatePolicy>never</updatePolicy>
      </releases>
    </pluginRepository>
  </pluginRepositories>

故当maven下载资源时,会优先使用http://repo.maven.apache.org/maven2去下载。

 

解决方法:

在项目pom.xml的<project>中添加:

<repositories>
    <repository>
        <id>alimaven</id>
        <url>https://maven.aliyun.com/repository/public</url>
    </repository>
</repositories>
 
<pluginRepositories>
    <pluginRepository>
        <id>alimaven</id>
        <url>https://maven.aliyun.com/repository/public</url>
    </pluginRepository>
</pluginRepositories>
北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3