基本结构

<settings xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd ">
<localRepository/>
<interactiveMode/>
<usePluginRegistry/>
<offline/>
<pluginGroups/>
<servers/>
<mirrors/>
<proxies/>
<profiles/>
<activeProfiles/>
</settings>

localRepository: 表示本地库的保存位置,也就是maven2主要的jar保存位置,默认在${user.dir}/.m2/repository,如果需要另外设置,就换成其他的路径。

如:

<localRepository>d:\oceanic_workspace\oceanic_maven_repo\repository</localRepository>

offline: 如果不想每次编译,都去查找远程中心库,那就设置为true。当然前提是你已经下载了必须的依赖包。 默认false。

<offline>false</offline>

Servers :在POM中的 distributionManagement元素定义了开发库。然而,特定的username和pwd不能使用于pom.xml,所以通过此配置来保存server信息。

  • id:server 的id,用于匹配distributionManagement库id,比较重要。
  • username, password:用于登陆此服务器的用户名和密码
  • privateKey, passphrase:设置private key,以及passphrase
  • filePermissions, directoryPermissions:当库文件或者目录创建后,需要使用权限进行访问。
    <servers>
<server>
<id>server001</id>
<username>my_login</username>
<password>my_password</password>
<privateKey>${usr.home}/.ssh/id_dsa</privateKey>
<passphrase>some_passphrase</passphrase>
<filePermissions>664</filePermissions>
<directoryPermissions>775</directoryPermissions>
<configuration></configuration>
</server>
<server>
<id>server002</id>
<username>my_login</username>
<password>my_password</password>
<privateKey>${usr.home}/.ssh/id_dsa</privateKey>
<passphrase>some_passphrase</passphrase>
<filePermissions>664</filePermissions>
<directoryPermissions>775</directoryPermissions>
<configuration></configuration>
</server>
</servers>

Mirrors
表示镜像库,指定库的镜像,用于增加其他库

  • id,name:唯一的标志,用于区别镜像
  • url:镜像的url
  • mirrorOf:此镜像指向的服务id
  <mirrors>
<mirror>
<id>planetmirror.com</id>
<name>PlanetMirror Australia</name>
<url>http://downloads.planetmirror.com/pub/maven2</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>

<mirrorOf> 表示只为central仓库做镜像,如果想为所有的仓库做镜像那么可以改为:<mirrorOf>*</mirrorOf>

Proxies 
此代理设置,主要用于无法直接访问中心的库用户配置。

  • id:代理的标志
  • active:是否激活代理
  • protocol, host, port:protocol://host:port 代理
  • username, password:用户名和密码
  • nonProxyHosts: 不需要代理的host
  <proxies>
<proxy>
<id>myproxy</id>
<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>

Profiles 
  类似于pom.xml中的profile元素

主要包括activation,repositories,pluginRepositories 和properties元素 
  刚开始接触的时候,会比较迷惑,这是maven2中比较强大的功能——个性配置。 
  单独定义profile后,并不会生效,需要通过满足条件来激活。

repositories 和pluginRepositories 依照如下的配置,定义了本地开发库,用于release 发布。

<repositories>
<repository>
<id>repo-local</id>
<name>Internal 开发库</name>
<url>http://192.168.0.2:8082/repo-local</url>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
<layout>default</layout>
</repository>
</repositories> <pluginRepositories>
<pluginRepository>
<id>repo-local</id>
<name>Internal 开发库</name>
<url>http://192.168.0.2:8082/repo-local</url>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
<layout>default</layout>
</pluginRepository>
</pluginRepositories>

releases, snapshots:每个产品的版本的Release或者snapshot(注:release和snapshot的区别,release一般是比较稳定的版本,而snapshot基本上不稳定,只是作为快照)

properties作为placeholder值,如ant的properties。

包括以下的5种类型值:

  1. env.X,返回当前的环境变量
  2. project.x:返回pom中定义的元素值,如project.version
  3. settings.x:返回settings.xml中定义的元素
  4. java 系统属性:所有经过java.lang.System.getProperties()返回的值
  5. x:用户自己设定的值

Activation 用于激活此profile

  • jdk:如果匹配指定的jdk版本,将会激活
  • os:操作系统
  • property:如果maven能检测到相应的属性
  • file: 用于判断文件是否存在或者不存在
    <activation>
<activeByDefault>false</activeByDefault>
<jdk>1.5</jdk>
<os>
<name>Windows XP</name>
<family>Windows</family>
<arch>x86</arch>
<version>5.1.2600</version>
</os>
<property>
<name>mavenVersion</name>
<value>2.0.3</value>
</property>
<file>
<exists>${basedir}/file2.properties</exists>
<missing>${basedir}/file1.properties</missing>
</file>
</activation>

Active Profiles

除了使用activation来激活profile,同样可以通过activeProfiles来激活

env-test 表示指定的profile id

  <activeProfiles>
    <activeProfile>env-test</activeProfile>
  </activeProfiles>

interactiveMode:表示是否使用交互模式,默认是true;如果设为false,那么当Maven需要用户进行输入的时候,它会使用一个默认值。

 <interactiveMode>true</interactiveMode>

pluginGroups:在pluginGroups元素下面可以定义一系列的pluginGroup元素。表示当通过plugin的前缀来解析plugin的时候到哪里寻找。pluginGroup元素指定的是plugin的groupId。默认情况下,Maven会自动把org.apache.maven.plugins和org.codehaus.mojo添加到pluginGroups下。

  <pluginGroups>
<pluginGroup>com.your.plugins</pluginGroup>
</pluginGroups>

参考资料:http://blog.csdn.net/jinshuaiwang/article/details/23686099

[maven] settings 文件节点配置详解的更多相关文章

  1. Mybatis中接口和对应的mapper文件位置配置详解

    Mybatis中接口和对应的mapper文件位置配置详解 原链接为:https://blog.csdn.net/fanfanzk1314/article/details/71480954 今天遇到一个 ...

  2. Maven项目pom.xml配置详解

    maven项目pom.xml文件配置详解,需要时可以用作参考: <project xmlns="http://maven.apache.org/POM/4.0.0" xmln ...

  3. Maven系列--setting.xml 配置详解

    文件存放位置 全局配置: ${M2_HOME}/conf/settings.xml 用户配置: ${user.home}/.m2/settings.xml note:用户配置优先于全局配置.${use ...

  4. Maven之setting.xml 配置详解

    文件存放位置 全局配置: ${M2_HOME}/conf/settings.xml 用户配置: ${user.home}/.m2/settings.xml note:用户配置优先于全局配置.${use ...

  5. Maven中setting.xml 配置详解

    文件存放位置 全局配置: ${M2_HOME}/conf/settings.xml 用户配置: ${user.home}/.m2/settings.xml note:用户配置优先于全局配置.${use ...

  6. maven setting.xml 中文配置详解(全配置)

    春节假期在家养病,乘有时间整理了下之前的知识——知识贵在归纳总结. 参照了官方文档,针对其中的一些未描述详尽的内容翻查了不少资料,补充到了配置文件中,同时再加上一些说明.例子,方便查阅. 内容虽然比较 ...

  7. Maven的pom.xml 配置详解

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/20 ...

  8. Maven系列--pom.xml 配置详解

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/20 ...

  9. Maven之pom.xml 配置详解

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/20 ...

随机推荐

  1. http_load的安装及使用方法

    http_load 程序非常小,解压后也不到100K http_load以并行复用的方式运行,用以测试web服务器的吞吐量与负载.但是它不同于大多数压力测试工 具,它可以以一个单一的进程运行,一般不会 ...

  2. Linux下指定版本编译安装LAMP

    说明: 操作系统:CentOS 6.5 64位 需求: 编译安装LAMP运行环境 各软件版本如下: MySQL:mysql-5.1.73 Apache:httpd-2.2.31 PHP:php-5.2 ...

  3. 计算5的阶乘并在JSP页面输出

    <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding= ...

  4. 【leetcode❤python】27. Remove Element

    #-*- coding: UTF-8 -*- class Solution(object):    def removeElement(self, nums, val):        "& ...

  5. BZOJ 3159决战

    题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=3159 题意:给出一棵树,(1)路径加一个值:(2)路径上的节点的值反转(只是值反转,不是节 ...

  6. Bson

    https://en.wikipedia.org/wiki/BSON BSON /ˈbiːsɒn/ is a computer data interchange format used mainly ...

  7. onclick事件分析

     有些时候,我们想实现这样的一种效果:      <a href="imgs/2.jpg" title="A fireworks display" onc ...

  8. NPN&PNP

    一.晶体管基础知识 晶体管分2种:NPN.PNP 晶体管通常封装为TO-92,下面是元件实物图 和 元件符合: NPN: 当电压和电流被加到基极上时,NPN晶体管: 其工作原理: 就像水龙头—给控制开 ...

  9. 将客户端将IE9强制为IE7

    有时候由于浏览器的问题我们在IE7中开发的东西需要在IE9中展示 但是会出现兼容性的问题. 那么我们可以同技巧将用户端的浏览器强行以IE7的文档模式展示我们的网页 下面是针对iis asp.net程序 ...

  10. javascript学习-原生javascript的小特效(简单的运动效果)

    前些日子看了个视频所以就模仿它的技术来为大家做出几个简单的JS小特效 一:运动特效(主要是通过改变元素的left,right,height,width,opacity来达到运动的效果) 我们今天做一个 ...