maven使用之settings.xml配置

-- Pageviews

maven

本 maven settings.xml相关配置是在做smnpo微服务相关组件时进行配置,包含nexus3 maven 私有仓库的搭建以及账号密码权限相关配置,具体可参考xml配置的详细信息。

日期更新内容
20190507新增pom.xml中添加repository不生效的解决方案
20190509将私有maven库改用到阿里云效并更新完整settings.xml

20190509

centos
今天抽空看了一下centos的cpu和mem使用情况,发现自建maven仓库造成内存消耗严重,于是将私有仓库切换到阿里云效

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<repositories>
<repository>
<id>rdc-releases</id>
<url>https://repo.rdc.aliyun.com/repository/71943-release-LWfjuf/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>rdc-snapshots</id>
<url>https://repo.rdc.aliyun.com/repository/71943-snapshot-gMBvZN/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>

20190507

项目pom.xml中的repository配置不生效的问题解析

1
2
3
4
5
6
<mirror>         
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>

错误就出在mirrorOf节点了,如果写*会覆盖掉所有的,不管是哪个repository,最后都被这个镜像所mirror掉了,导致pom文件中的repository不生效了。
解决方案也很简单,把这个mirrorOf改掉就好了。具体修改建议参考maven官方说明:
1
2
3
4
* = everything
external:* = everything not on the localhost and not file based.
repo,repo1 = repo or repo1
*,!repo1 = everything except repo1

20190505

完整settings.xml如下:

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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124

<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<mirrors>
<mirror>
<id>mirror</id>
<mirrorOf>!rdc-releases,!rdc-snapshots</mirrorOf>
<name>mirror</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>

</mirrors>
<servers>
<server>
<id>rdc-releases</id>
<username>vC1AQt</username>
<password>联系SnailDev</password>
</server>
<server>
<id>rdc-snapshots</id>
<username>vC1AQt</username>
<password>联系SnailDev</password>
</server>
</servers>
<profiles>
<profile>
<id>nexus</id>
<repositories>
<repository>
<id>central</id>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>snapshots</id>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>rdc-releases</id>
<url>https://repo.rdc.aliyun.com/repository/71943-release-LWfjuf/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>rdc-snapshots</id>
<url>https://repo.rdc.aliyun.com/repository/71943-snapshot-gMBvZN/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>snapshots</id>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>rdc-releases</id>
<url>https://repo.rdc.aliyun.com/repository/71943-release-LWfjuf/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>rdc-snapshots</id>
<url>https://repo.rdc.aliyun.com/repository/71943-snapshot-gMBvZN/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>

</profiles>

<activeProfiles>
<activeProfile>nexus</activeProfile>

</activeProfiles>


</settings>