前提:maven的settings中已经配置好私有仓库
pom中所有的jar包都是从私有仓库下载,但是!!!执行mvn的插件还是会从https://repo.maven.apache.org/maven2这个maven的网站上下载.我是在使用jenkins自动部署的时候出现的这个问题,不知道其他人是什么时候出现的.
上网查找了许多资料,因为不知道如何搜索,费了一些功夫,最后才找到,mvn的插件去maven地址下载的原因是
所有的pom文件都是继承了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官方仓库的地址,我们需要手动更改地址为自己的maven私有仓库地址
在自定义pom中添加
<repositories>
<repository>
<id>central</id>
<url>http://host:port/content/groups/public(这里换成自己的私有maven仓库地址)</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://host:port/content/groups/public(这里换成自己的私有maven仓库地址)</url>
</pluginRepository>
</pluginRepositories>