maven仓库提示“Downloading: http://repo.maven.apache.org/maven2/”

问题描述

maven setting.xml中配置私有库,但是在mvn install时仍然提示Downloading: http://repo.maven.apache.org/maven2/

原因

网上查了很多资料发现了解到所有自定义pom.xml都是继承自super pom,所以maven项目下载一些jar包时,默认会从中央仓库下载

<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>

解决办法

在项目的pom文件中手动指定下私有仓库

<repositories>
    <repository>
        <id>hanxiaohan</id>
        <url>http://host:port/content/groups/public</url>
    </repository>
</repositories>

<pluginRepositories>
    <pluginRepository>
        <id>hanxiaohan</id>
        <url>http://host:port/content/groups/public</url>
    </pluginRepository>
</pluginRepositories>

猜你喜欢

转载自www.cnblogs.com/handongxue/p/12274903.html