maven私有库神坑之:“Downloading: http://repo.maven.apache.org/maven2/”深坑!!!!!!坑害了一周时间

现象

即使配置了私有库,并且在maven setting.xml中配置了mirror,但是,经常会遇到执行mvn命令的时候,会提醒:
Downloading: http://repo.maven.apache.org/maven2/
原因

所有自定义pom.xml都是继承自super pom:

 1  <repositories>
 2     <repository>
 3       <id>central</id>
 4       <name>Central Repository</name>
 5       <url>http://repo.maven.apache.org/maven2</url>
 6       <layout>default</layout>
 7       <snapshots>
 8         <enabled>false</enabled>
 9       </snapshots>
10     </repository>
11   </repositories>
12 
13   <pluginRepositories>
14     <pluginRepository>
15       <id>central</id>
16       <name>Central Repository</name>
17       <url>http://repo.maven.apache.org/maven2</url>
18       <layout>default</layout>
19       <snapshots>
20         <enabled>false</enabled>
21       </snapshots>
22       <releases>
23         <updatePolicy>never</updatePolicy>
24       </releases>
25     </pluginRepository>
26   </pluginRepositories>


因此,当maven项目需要下载一些metadata、pom、jar的时候,会优先去中央仓库下载,导致内网用户各种报错!
解决办法:

在项目pom.xml中添加如下配置:

 1 <repositories>
 2     <repository>
 3         <id>central</id>
 4         <url>http://host:port/content/groups/public</url>
 5     </repository>
 6 </repositories>
 7 
 8 <pluginRepositories>
 9     <pluginRepository>
10         <id>central</id>
11         <url>http://host:port/content/groups/public</url>
12     </pluginRepository>
13 </pluginRepositories> 


————————————————
版权声明:本文为CSDN博主「你好时光未老」的原创文章。
原文链接:https://blog.csdn.net/qq_40369435/java/article/details/96881611

posted @ 2020-04-13 16:28  会跑的蚂蚁  阅读(7907)  评论(2编辑  收藏  举报