maven多个私服的配置

参考文档

https://www.cnblogs.com/Rocky_/p/16824997.html

https://blog.csdn.net/qq_35606010/article/details/139479856

本地的私服设置(settings.xml)

 1<?xml version="1.0" encoding="UTF-8"?>
 2
 3<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
 4          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 5          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
 6
 7  <!-- 本地仓库地址 -->
 8  <localRepository>D:\dev\maven-repository</localRepository>
 9
10  <servers>  
11    <!-- copote 私服的账号信息 -->
12    <server>
13      <id>copote-releases</id>
14      <username>admin</username>
15      <password>copote</password>
16    </server>
17
18    <!-- copote 私服的账号信息 -->
19    <server>
20      <id>copote-snapshots</id>
21      <username>admin</username>
22      <password>copote</password>
23    </server>
24
25    <!-- aliyun 私服的账号信息 -->
26    <server>
27      <id>aliyun-cgg</id>
28      <username>65a726a78f25556ebb9b2ff0</username>
29      <password>UxidlsEFm1SY</password>
30    </server>
31  </servers>
32
33  <profiles>
34    <profile>
35      <id>default-profile</id>
36      <repositories>
37        <!-- aliyun 公共仓库地址 -->
38        <repository>
39          <id>aliyun-public</id>
40          <url>https://maven.aliyun.com/repository/public</url>
41          <releases>
42            <enabled>true</enabled>
43          </releases>
44          <snapshots>
45            <enabled>true</enabled>
46          </snapshots>
47        </repository>
48
49        <!-- copote 私服地址 -->
50        <!-- 从 copote 私服上下载文件是不需要用户名/密码的,因此, repository 的 id 随便取,只要保证唯一就好 -->
51        <repository>
52          <id>copote-public</id>
53          <url>http://210.210.210.19:8008/repository/maven-public/</url>
54          <releases>
55            <enabled>true</enabled>
56          </releases>
57          <snapshots>
58            <enabled>true</enabled>
59          </snapshots>
60        </repository>
61
62        <!-- aliyun 私服地址 -->
63        <!-- 注意:因为在 aliyun 私服下载依赖包也需要用户名/密码,因此 repository 的 id 必须和上面 server 的节点 id 保持一致 -->
64        <repository>
65          <id>aliyun-cgg</id>
66          <url>https://packages.aliyun.com/65a726d70cab697efe135cc5/maven/cgg</url>
67          <releases>
68            <enabled>true</enabled>
69          </releases>
70          <snapshots>
71            <enabled>true</enabled>
72          </snapshots>
73        </repository>
74      </repositories>
75
76      <pluginRepositories>
77        <!-- aliyun 公共仓库地址 -->
78        <pluginRepository>
79            <id>aliyun-public</id>
80            <url>https://maven.aliyun.com/repository/public</url>
81            <releases>
82                <enabled>true</enabled>
83            </releases>
84            <snapshots>
85                <enabled>true</enabled>
86            </snapshots>
87        </pluginRepository>
88    </pluginRepositories>
89    </profile>
90  </profiles>
91
92  <!-- 默认启用的配置 -->
93  <activeProfiles>
94    <activeProfile>default-profile</activeProfile>
95  </activeProfiles>
96</settings>

项目中的私服设置(pom.xml)

 1<?xml version="1.0" encoding="UTF-8"?>
 2<project xmlns="http://maven.apache.org/POM/4.0.0"
 3         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 4         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
 5    <modelVersion>4.0.0</modelVersion>
 6
 7    <groupId>org.example</groupId>
 8    <artifactId>Test</artifactId>
 9    <version>1.0-SNAPSHOT</version>
10
11    <properties>
12        <maven.compiler.source>8</maven.compiler.source>
13        <maven.compiler.target>8</maven.compiler.target>
14        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
15    </properties>
16
17    <dependencies>
18        <dependency>
19            <groupId>org.core.code</groupId>
20            <artifactId>code-core</artifactId>
21            <version>1.8.11</version>
22        </dependency>
23    </dependencies>
24
25    <distributionManagement>
26        <!-- 打包到 aliyun 的私服需要用户名/密码 -->
27        <!-- 因此,repository 的 id 必须与 setting.xml 中的 server 节点的 id 保持一致-->
28        <repository>
29            <id>aliyun-cgg</id>
30            <name>aliyun private repository</name>
31            <url>https://packages.aliyun.com/65a726d70cab697efe135cc5/maven/cgg</url>
32        </repository>
33    </distributionManagement>
34</project>