maven如何配置多个仓库?本篇文章小编给大家分享一下maven配置多个仓库方法,文章代码介绍的很详细,小编觉得挺不错的,现在分享给大家供大家参考,有需要的小伙伴们可以来看看。
1、方法一
之前在配置 Maven 的 settings.xml 时,都会设置 mirror 节点,例如:
alimaven aliyun maven http://maven.aliyun.com/nexus/content/groups/public/ central
然后第一想法就是在 mirrors 节点下多增加几个 mirror,然而并不可以。正确的操作是在 profiles 节点下配置多个 profile,而且配置之后要激活。例如:
配置profiles
boundlessgeo boundlessgeo https://repo.boundlessgeo.com/main/ true true always aliyun aliyun http://maven.aliyun.com/nexus/content/groups/public/ true true always maven-central maven-central http://central.maven.org/maven2/ true true always
通过配置 activeProfiles 子节点激活
boundlessgeo aliyun maven-central
如果在IDE里,记得要更新生效,然后就可以了。
2、 方法二
在项目中添加多个仓库,是通过修改项目中的pom文件实现的。
思路:在项目中pom文件的repositories节点(如果没有手动添加)下添加多个repository节点,每个repository节点是一个仓库。
jboss-repository jboss repository http://repository.jboss.org/nexus/content/groups/public-jboss/ aliyun-repository aliyun repository http://maven.aliyun.com/nexus/content/groups/public/ 奇葩仓库 https://奇葩仓库/public/