Nexus Maven私服配置
客户端会从maven-public拉取,如果只关联两个私有仓库releases和snapshots,拉取不到时客户端回去其他镜像拉取。
如果关联了阿里云,中心仓库等,在客户端拉取时会认为可以在私服拉取到,所以在私服做跳板拉取。
这里我的实现方式时让私服public只关联两个私有仓库,客户端配置时配置多个镜像,不走跳板,私服有的在私服拉,没有的去阿里云或中央仓库拉。
我的maven客户端配置:
<?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">
<localRepository>./repository</localRepository>
<pluginGroups>
<pluginGroup>org.sonatype.plugins</pluginGroup>
</pluginGroups>
<servers>
<server>
<id>nexus</id>
<username>ldap用户名</username>
<password>ldap密码</password>
</server>
<server>
<id>releases</id>
<username>ldap用户名</username>
<password>ldap密码</password>
</server>
<server>
<id>snapshots</id>
<username>robot</username>
<password>ldap密码</password>
</server>
</servers>
<mirrors>
<mirror>
<id>central</id>
<mirrorOf>central</mirrorOf>
<name>central</name>
<url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
<blocked>false</blocked>
</mirror>
<mirror>
<id>alimaven</id>
<mirrorOf>aliyun</mirrorOf>
<name>阿里云</name>
<url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
<blocked>false</blocked>
</mirror>
<mirror>
<id>nexus</id>
<mirrorOf>nexus</mirrorOf>
<name>私服</name>
<url>http://nexus.dev.dra-m.com/repository/maven-public/</url>
<blocked>false</blocked>
</mirror>
</mirrors>
<profiles>
<profile>
<id>nexus</id>
<properties>
<altSnapshotDeploymentRepository>snapshots::default::http://nexus.dev.dra-m.com/repository/maven-snapshots/</altSnapshotDeploymentRepository>
<altReleaseDeploymentRepository>releases::default::http://nexus.dev.dra-m.com/repository/maven-releases/</altReleaseDeploymentRepository>
</properties>
</profile>
<profile>
<id>dev</id>
<repositories>
<repository>
<id>nexus</id>
<name>私服</name>
<url>http://nexus.dev.dra-m.com/repository/maven-public/</url>
<blocked>false</blocked>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<updatePolicy>always</updatePolicy>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>aliyun</id>
<name>阿里云</name>
<url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
<blocked>false</blocked>
<releases>
<enabled>true</enabled>
</releases>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>plugins</id>
<name>Plugin 阿里云</name>
<url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
<blocked>false</blocked>
</pluginRepository>
<pluginRepository>
<id>plugins</id>
<name>Plugin 私服</name>
<url>http://nexus.dev.dra-m.com/repository/maven-public/</url>
<blocked>false</blocked>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>dev</activeProfile>
</activeProfiles>
</settings>
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
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
设置Blocked标签是因为新版Maven校验了HTTPS,如果不设置为False无法拉取
设置了snapshots每次都重新拉取
上传配置:
<distributionManagement>
<repository>
<id>releases</id>
<name>Nexus Release Repository</name>
<url>http://nexus.dev.dra-m.com/repository/maven-releases/</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<name>Nexus Snapshot Repository</name>
<url>http://nexus.dev.dra-m.com/repository/maven-snapshots/</url>
</snapshotRepository>
</distributionManagement>
1
2
3
4
5
6
7
8
9
10
11
12
2
3
4
5
6
7
8
9
10
11
12
上次更新: 10/23/2024