08.基于IDEA+Spring+Maven搭建测试项目--Maven的配置文件settings.xml

 1 <?xml version="1.0" encoding="UTF-8"?>
 2 <settings xmlns="http://maven.apache.org/SETTINGS/4.0.0" 
 3           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
 4           xsi:schemaLocation="http://maven.apache.org/SETTINGS/4.0.0 http://maven.apache.org/xsd/settings-4.0.0.xsd">
 5   <!--本地仓库。该值表示构建系统本地仓库的路径。其默认值为%USER_HOME%/.m2/repository。-->
 6    <localRepository>F:JavaMaven
epository</localRepository> 
 7 
 8   <!--表示Maven是否需要在离线模式下运行。如果构建系统需要在离线模式下运行,则为true,默认为false。当由于网络设置原因或者安全因素,构建服务器不能连接远程仓库的时候,该配置就十分有用。 -->  
 9   <offline>false</offline>
10 
11   <!-- 远程服务器部署地址配置,笔者公司信息,敏感原因去掉password -->
12   <servers>
13     <server>
14       <id>public</id>
15       <username>developer</username>
16       <password></password>
17     </server>
18     <server>
19       <id>releases</id>
20       <username>developer</username>
21       <password></password>
22     </server>
23     <server>
24       <id>snapshots</id>
25       <username>developer</username>
26       <password></password>
27     </server>
28   </servers>
29   
30   <!--设置包下载路径。-->
31   <!--定义公共仓库,除此之外,可能还会配置公司仓库地址-->
32   <mirrors>
33       <!-- 阿里云仓库 -->
34       <mirror>
35      <id>nexus-aliyun</id>
36       <mirrorOf>central</mirrorOf>
37       <name>Nexus aliyun</name>
38       <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
39     </mirror> 
40       <!-- 中央云仓库 -->
41       <mirror>
42           <id>repo</id>
43           <mirrorOf>central</mirrorOf>
44           <name>Human Readable Name for this Mirror.</name>
45           <url>http://repo1.maven.org/maven2/</url>
46       </mirror>
47   
48   </mirrors>
49   
50   <!--根据环境参数来调整构建配置的列表,笔者公司信息,过滤掉参数。-->
51   <!--settings.xml中的profile元素是pom.xml中profile元素的裁剪版本。-->
52   <!--它包含了id,activation, repositories, pluginRepositories和 properties元素。-->
53   <!--这里的profile元素只包含这五个子元素是因为这里只关心构建系统这个整体(这正是settings.xml文件的角色定位),而非单独的项目对象模型设置。-->
54   <!--如果一个settings中的profile被激活,它的值会覆盖任何其它定义在POM中或者profile.xml中的带有相同id的profile。 -->
55   
56   <profiles>
57     <profile>
58       <id>ht-dev</id>
59       <!--定义的公共仓库。-->
60       <repositories>
61         <repository>
62           <id>public</id>
63           <url>http://localhost/nexus/content/groups/public/</url>
64           <snapshots><enabled>true</enabled><updatePolicy>always</updatePolicy></snapshots>
65         </repository>
66       </repositories>
67       <pluginRepositories>
68         <pluginRepository>
69           <id>public</id>
70           <url>http://localhost/nexus/content/groups/public/</url>
71           <snapshots><enabled>true</enabled></snapshots>
72         </pluginRepository>
73       </pluginRepositories>
74     </profile>
75   </profiles>
76   
77   <!--手动激活profiles的列表,按照profile被应用的顺序定义activeProfile。 -->
78   <!--该元素包含了一组activeProfile元素,每个activeProfile都含有一个profile id。 -->
79   <!--任何在activeProfile中定义的profile id,不论环境设置如何,其对应的profile都会被激活。如果没有匹配的profile,则什么都不会发生。-->
80   <!--例如,env-test是一个activeProfile,则在pom.xml(或者profile.xml)中对应id的profile会被激活。如果运行过程中找不到这样一个profile,Maven则会像往常一样运行。 --> 
81   <activeProfiles>
82     <activeProfile>ht-dev</activeProfile>
83   </activeProfiles>
84 </settings>

 详细搭建过程参考:https://www.cnblogs.com/xiuxingzhe/p/9250737.html

原文地址:https://www.cnblogs.com/xiuxingzhe/p/9250838.html