<?xml version="1.0"?>
<!-- ======================================================================== -->
<!-- settings.xml for maven users -->
<!-- Version: 3 -->
<!-- Auhtor: jingshun shi -->
<!-- $Id$ -->
<!-- ======================================================================== -->
<settings>
<!-- ======================================================================== -->
<!-- Accounts for SCM ONLY -->
<!-- ======================================================================== -->
<!--设置本地maven库,jar的存放位置-->
<localRepository>D:/company/.m2</localRepository>
<!--为仓库列表配置的下载镜像列表。 -->
<mirrors>
<!--给定仓库的下载镜像。mirrorOf用于指定那些仓库需要使用镜像,即使用对应mirror中的url(一般是私服路径)。指定后到原仓库下载的请求都会拦截到这个url上,如果这个url不包括中央库则这个url找不到后还会到中央库,如果包括了则不再尝试中央库 -->
<mirror>
<!--该镜像的唯一标识符。id用来区分不同的mirror元素。 -->
<id>planetmirror.com</id>
<!--镜像名称 -->
<name>PlanetMirror Australia</name>
<!--该镜像的URL。构建系统会优先考虑使用该URL,而非使用默认的服务器URL。 -->
<url>http://downloads.planetmirror.com/pub/maven2</url>
<!--被镜像的服务器的id。例如,如果我们要设置了一个Maven中央仓库(http://repo1.maven.org/maven2)的镜像,-->
<!--就需要将该元素设置成central。这必须和中央仓库的id central完全一致。 -->
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
<!--用来配置不同的代理,多代理profiles可以应对笔记本或移动设备的工作环境:通过简单的设置profile id就可以很容易的更换整个代理配置。 可以让该机器代理访问中心库-->
<proxies>
<!--代理元素包含配置代理时需要的信息 -->
<proxy>
<!--代理的唯一定义符,用来区分不同的代理元素。 -->
<id>myproxy</id>
<!--该代理是否是激活的那个。true则激活代理。当我们声明了一组代理,而某个时候只需要激活一个代理的时候,该元素就可以派上用处。 -->
<active>true</active>
<!--代理的协议。 协议://主机名:端口,分隔成离散的元素以方便配置。 -->
<protocol>http://…</protocol>
<!--代理的主机名。协议://主机名:端口,分隔成离散的元素以方便配置。 -->
<host>proxy.somewhere.com</host>
<!--代理的端口。协议://主机名:端口,分隔成离散的元素以方便配置。 -->
<port>8080</port>
<!--代理的用户名,用户名和密码表示代理服务器认证的登录名和密码。 -->
<username>proxyuser</username>
<!--代理的密码,用户名和密码表示代理服务器认证的登录名和密码。 -->
<password>somepassword</password>
<!--不该被代理的主机名列表。该列表的分隔符由代理服务器指定;例子中使用了竖线分隔符,使用逗号分隔也很常见。 -->
<nonProxyHosts>*.google.com|ibiblio.org</nonProxyHosts>
</proxy>
</proxies>
<servers>
<server>
<!--这个是ID是要和maven私服上对应的库一致,他也用于后边distributionManagement调用-->
<id>b2b.repo.server</id>
<!--服务器认证所需要的帐号-->
<username>companyName</username>
<!--服务器认证所需要的密码-->
<password>secret</password>
</server>
<!-- 配置tomcat-/manager/text 访问权限,详建maven部署tomcat -->
<server>
<id>tomcat</id>
<username>admin</username>
<password>admin</password>
</server>
</servers>
<!-- ======================================================================== -->
<!-- Profiles -->
<!-- ======================================================================== -->
<profiles>
<profile>
<!-- ======================================================================== -->
<!-- Managed Repositories for company Dev,include tabao repos and center repo-->
<!-- ======================================================================== -->
<id>company</id>
<!--profile默认是否激活的标识 -->
<activeByDefault>false</activeByDefault>
<!--activation有一个内建的java版本检测,如果检测到jdk版本与期待的一样,profile被激活。固有的! -->
<jdk>1.7</jdk>
<!--当匹配的操作系统属性被检测到,profile被激活。os元素可以定义一些操作系统相关的属性。 固有的!-->
<os>
<!--激活profile的操作系统的名字 -->
<name>Windows XP</name>
<!--激活profile的操作系统所属家族(如 'windows') -->
<family>Windows</family>
<!--激活profile的操作系统体系结构 -->
<arch>x86</arch>
<!--激活profile的操作系统版本 -->
<version>5.1.2600</version>
</os>
<!--如果Maven检测到某一个属性(其值可以在POM中通过${名称}引用),其拥有对应的名称和值,Profile就会被激活。-->
<!--如果值字段是空的,那么存在属性名称字段就会激活profile,否则按区分大小写方式匹配属性值字段 。固有的!-->
<property>
<!--激活profile的属性的名称 -->
<name>mavenVersion</name>
<!--激活profile的属性的值 -->
<value>2.0.3</value>
</property>
<!--提供一个文件名,通过检测该文件的存在或不存在来激活profile。missing检查文件是否存在,如果不存在则激活profile。-->
<!--另一方面,exists则会检查文件是否存在,如果存在则激活profile。 -->
<file>
<!--如果指定的文件存在,则激活profile。 -->
<exists>/usr/local/hudson/hudson-home/jobs/maven-guide-zh-to-production/workspace/</exists>
<!--如果指定的文件不存在,则激活profile。 -->
<missing>/usr/local/hudson/hudson-home/jobs/maven-guide-zh-to-production/workspace/</missing>
</file>
</activation>
<!--使用的仓库配置-->
<repositories>
<repository>
<id>central</id>
<name>company Repositories Group</name>
<url>http://repo.company-inc.com/nexus/content/groups/alirepositiry/</url>
</repository>
</repositories>
<!-- ======================================================================== -->
<!-- Repositories for maven plugins -->
<!-- ======================================================================== -->
<!--使用插件配置-->
<pluginRepositories>
<pluginRepository>
<id>central</id>
<name>company Plugin Repos Group</name>
<url>http://repo.company-inc.com/nexus/content/groups/alirepositiry/</url>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<!--当一个插件被使用但groupId没被指明,就会搜索这个pluginGroups-->
<pluginGroups>
<pluginGroup>com.company.org.apache.maven.plugins</pluginGroup>
<pluginGroup>com.company.maven.plugins</pluginGroup>
</pluginGroups>
<!--无条件激活company这个配置文件,激活后就会使用这个profile中的配置-->
<activeProfiles>
<activeProfile>company</activeProfile>
</activeProfiles>
</settings>
补充:
1、 distributionManagement配置在maven项目的pom中,用于用于配置管理构件。用户通过该配置指定自己的构件(jar、文档等)发布的服务器等相关信息,发布后其他人可以在私服上看到并引用。
<distributionManagement>
<repository>
<id>maven-releases</id>
<name>maven-releases</name>
<url>http://ip:8081/repository/maven-releases/</url>
</repository>
<snapshotRepository>
<id>maven-snapshots</id>
<name>maven-snapshots</name>
<url>http://ip:8081/repository/maven-snapshots/</url>
</snapshotRepository>
</distributionManagement>
2、maven部署tomcat
a、maven可以通过tomcat7:redeploy类似在tomcat启动的情况下实现热部署,但tomcat7开始默认没有配置tomcat-manage的权限。
b、要让这种热部署的功能生效就要tomcat-users.xml中配置帐号/密码及相关的权限,这样maven就能够操作tomcat了。
3、profile文件中的配置包括四种节点,激活(activation)、仓库(repositories)、插件仓库(pluginRepositories)、属性(properties),一个profile文件激活后就会覆盖到pom文件中去。
a、profile的激活条件有os(系统参数),jdk(jdk版本),property(属性值),file(文件是否存在)
4、阿里的镜像路径:
http://maven.aliyun.com/nexus/content/groups/public