maven多仓库配置 - 公司仓库与阿里云仓库共存

以下操作在 maven 配置文件 settings.xml 中修改

配置公司账户信息 server

1
2
3
4
5
6
7
<servers>
<server>
<id>nexus</id>
<username>xxx</username>
<password>xxx</password>
</server>
</servers>

删除掉原来的 mirror

1
2
<mirrors>
</mirrors>

配置公司和阿里云 profile

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
<profiles>
<profile>
<id>nexus</id>
<repositories>
<repository>
<id>nexus-pub</id>
<name>private-nexus</name>
<url>http://192.168.50.1:8899/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>nexus-pub</id>
<name>private nexus</name>
<url>http://192.168.50.1:8899/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
<profile>
<id>aliyun</id>
<repositories>
<repository>
<id>central</id>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>

配置 activeProfiles

1
2
3
4
<activeProfiles>
<activeProfile>nexus</activeProfile>
<activeProfile>aliyun</activeProfile>
</activeProfiles>