maven 配置多个仓库
1>方法一
之前在配置 Maven 的 settings.xml 时,都会设置 mirror 节点,例如:
| 1 2 3 4 5 6 7 8 |
//maven.aliyun.com/nexus/content/groups/public/
|
然后第一想法就是在 mirrors 节点下多增加几个 mirror,然而并不可以。正确的操作是在 profiles 节点下配置多个 profile,而且配置之后要激活。例如:
配置profiles
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
//repo.boundlessgeo.com/main/
true
true
//maven.aliyun.com/nexus/content/groups/public/
true
true
//central.maven.org/maven2/
true
true
|
通过配置 activeProfiles 子节点激活
| 1 2 3 4 5 |
|
如果在IDE里,记得要更新生效,然后就可以了。
2> 方法二
在项目中添加多个仓库,是通过修改项目中的pom文件实现的。
思路:在项目中pom文件的repositories节点(如果没有手动添加)下添加多个repository节点,每个repository节点是一个仓库。
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
//repository.jboss.org/nexus/content/groups/public-jboss/
//maven.aliyun.com/nexus/content/groups/public/
//奇葩仓库/public/
|