問題描述
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>
