maven私有庫神坑之:“Downloading: http://repo.maven.apache.org/maven2/”
現象:
即使你配置了私有庫,并且在maven setting.xml中配置了mirror,但是,經常會遇到執行mvn指令的時候,會提醒:
Downloading: http://repo.maven.apache.org/maven2/
原因:
所有自定義pom.xml都是繼承自super pom:
http://maven.apache.org/ref/3.0.4/maven-model-builder/super-pom.html
super 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項目需要下載下傳一些metadata、pom、jar的時候,會優先去中央倉庫下載下傳,導緻内網使用者各種報錯!
<repositories>
<repository>
<id>central</id>
<url>http://host:port/content/groups/public</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://host:port/content/groups/public</url>
</pluginRepository>
</pluginRepositories>