1 <?xml version="1.0" encoding="UTF-8"?>
 2 <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" 
 3           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
 4           xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
 5 
 6   <pluginGroups></pluginGroups>
 7   <proxies></proxies>
 8 
 9   <servers>
10       <server>
11       <id>nexus-releases</id>
12       <username>admin</username>
13       <password>admin123</password>
14     </server>
15     <server>
16       <id>nexus-snapshots</id>
17       <username>admin</username>
18       <password>admin123</password>
19     </server>
20   </servers>
21 
22   <mirrors> 
23     <mirror> 
24       <id>nexus-releases</id> 
25       <mirrorOf>*</mirrorOf> 
26       <url>http://localhost:8081/nexus/content/groups/public</url> 
27     </mirror>
28     <mirror> 
29       <id>nexus-snapshots</id> 
30       <mirrorOf>*</mirrorOf> 
31       <url>http://localhost:8081/nexus/content/groups/public-snapshots</url> 
32     </mirror> 
33   </mirrors> 
34  
35   <profiles>
36    <profile>
37       <id>nexus</id>
38       <repositories>
39         <repository>
40           <id>nexus-releases</id>
41           <url>http://nexus-releases</url>
42           <releases><enabled>true</enabled></releases>
43           <snapshots><enabled>true</enabled></snapshots>
44         </repository>
45         <repository>
46           <id>nexus-snapshots</id>
47           <url>http://nexus-snapshots</url>
48           <releases><enabled>true</enabled></releases>
49           <snapshots><enabled>true</enabled></snapshots>
50         </repository>
51       </repositories>
52       <pluginRepositories>
53          <pluginRepository>
54                 <id>nexus-releases</id>
55                  <url>http://nexus-releases</url>
56                  <releases><enabled>true</enabled></releases>
57                  <snapshots><enabled>true</enabled></snapshots>
58                </pluginRepository>
59                <pluginRepository>
60                  <id>nexus-snapshots</id>
61                   <url>http://nexus-snapshots</url>
62                 <releases><enabled>true</enabled></releases>
63                  <snapshots><enabled>true</enabled></snapshots>
64              </pluginRepository>
65          </pluginRepositories>
66     </profile>
67   </profiles>
68 
69   <activeProfiles>
70       <activeProfile>nexus</activeProfile>
71   </activeProfiles>
72  
73 </settings>

maven 项目 的pom.xml配置

 1 <distributionManagement>
 2         <!-- 两个ID必须与 setting.xml中的<server><id>nexus-releases</id></server>保持一致-->
 3         <repository>
 4             <id>nexus-releases</id>
 5             <name>Nexus Release Repository</name>
 6             <url>http://localhost:8081/nexus/content/repositories/releases</url>
 7         </repository>
 8         <snapshotRepository>
 9             <id>nexus-snapshots</id>
10             <name>Nexus Snapshot Repository</name>
11             <url>http://localhost:8081/nexus/content/repositories/snapshots</url>
12         </snapshotRepository>
13     </distributionManagement>