maven - settings.xml文件详解
Settings.xml配置文件详解
maven默认的settings.xml是一个包含注释和例子的模板,可以快速的修改settings.xml文件
maven安装后不会在用户目录下自动生成settings.xml,一般是将/maven/conf下的settings.xml文件拷贝过去进行相应的修
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"> <!-- 本地仓库的路径,默认值是~/.m2/repository -->
<localRepository>/path/to/local/repo</localRepository> <!-- maven是否需要和用户交互,默认值是true -->
<interactiveMode>true</interactiveMode> <!-- 是否使用plugin-registry.xml文件来管理插件版本 -->
<usePluginRegistry>false</usePluginRegistry>
<!--
maven是否需要在离线模式下运行
true:一般用于构建服务器不能连接远程仓库的时候,基于网络或者安全考虑
默认为false -->
<offline>false</offline> <!--
当插件的组织ID(groupId)没有提供的时候,供搜寻插件组织的列表
包含<pluginGroup>元素列表,每一个子元素包含一个组织ID(groupId)
默认包含org.apache.maven.plugins -->
<pluginGroups>
<!-- plugin的组织ID(groupId) -->
<pluginGroup>com.your.plugins</pluginGroup>
</pluginGroups> <!-- 配置多种代理,包含<proxy>元素 -->
<proxies>
<!-- 配置代理时需要的信息 -->
<proxy>
<!-- 代理唯一id,用于区分不同的代理 -->
<id>optional</id>
<!-- 代理是否激活 -->
<active>true</active>
<!-- 代理的协议 -->
<protocol>http</protocol>
<!-- 代理的用户名,表示代理服务器认证的登录名/密码 -->
<username>proxyuser</username>
<!-- 代理的密码 -->
<password>proxypass</password>
<!-- 代理的主机名 -->
<host>proxy.host.net</host>
<!-- 代理的端口 -->
<port>80</port>
<!-- 不被代理的主机名列表 -->
<nonProxyHosts>local.net|some.host.com</nonProxyHosts>
</proxy>
</proxies> <!-- 配置服务端的设置,包含server元素-->
<servers>
<!-- 包含配置服务器是需要的信息 -->
<server>
<!-- server的id,与distributionManagement中repository的id相匹配 -->
<id>deploymentRepo</id>
<!-- 鉴权用户名,表示服务器认证需要的用户名/密码 -->
<username>repouser</username>
<!-- 鉴权密码 -->
<password>repopwd</password>
<!-- 鉴权时使用的私钥位置,私钥位置和私钥密码指定一个私钥的路径(默认是/home/hudson/.ssh/id_dsa) -->
<privateKey>/path/to/private/key</privateKey>
<!-- 鉴权时使用的私钥密码 -->
<passphrase>optional; leave empty if not used.</passphrase>
<!--
文件被创建时的权限,如果在部署的时候会创建一个仓库文件或者目录,这时需要使用权限
该元素的合法值是一个三位数字,对应unix文件系统的权限 -->
<filePermissions>664</filePermissions>
<!-- 目录创建时的权限 -->
<directoryPermissions>775</directoryPermissions>
<!-- 传输层的额外配置项 -->
<configuration></configuration>
</server>
</servers> <!-- 下载的镜像列表 -->
<mirrors>
<!-- 镜像信息 -->
<mirror>
<!-- 镜像唯一标识 -->
<id>mirrorId</id>
<!-- -->
<mirrorOf>repositoryId</mirrorOf>
<!-- 镜像名称 -->
<name>Human Readable Name for this Mirror.</name>
<!-- 镜像URL -->
<url>http://my.repository.com/repo/path</url>
</mirror>
</mirrors> <!--
根据环境参数来调整构建配置的列表
settings.xml中的profiles是pom.xml中profiles的裁剪版
包含<id>,<activation>,<repository>,<pluginRepository>,<properties>元素
settings.xml中的profiles只包含这几个元素是因为settings.xml文件只关心构建系统的整体而非单独的项目对象模型设置
如果一个profile被激活,它的值会覆盖任何其定义在pom.xml或profile.xml中相同id的profile -->
<profiles>
<!-- 根据环境参数调整构建配置 -->
<profile>
<!-- 该配置的唯一标识 -->
<id>jdk-1.4</id>
<!--
自动触发profile的逻辑条件
和pom.xml中的profile一样,在特定的环境中自动使用某些特定的值
这些特定的值通过activation指定 -->
<activation>
<!-- profile默认是否激活,默认false -->
<activeByDefault>false</activeByDefault>
<!-- activation有一个java版本检测,如果检测的版本与当前配置一致则profile被激活 -->
<jdk>1.4</jdk>
<!-- 当匹配的操作系统属性被检测到时,profile被激活 -->
<os>
<!-- 操作系统名称 -->
<name>Windows XP</name>
<!-- 操作系统所属的家族 -->
<family>Windows</family>
<!-- 操作系统体系结构 -->
<arch>x86</arch>
<!-- 操作系统版本 -->
<version>5.1.2600<version>
</os>
<!-- 属性检测,如果拥有对应的名称和值,profile将会被激活 -->
<property>
<!-- 激活profile的属性名称 -->
<name>mavenVersion</name>
<!-- 激活profile的值 -->
<value>2.0.3</value>
</property>
<!-- 通过检测文件是否存在激活profile -->
<file>
<!-- 文件存在则激活profile -->
<exists>/usr/local/min/workspace</exists>
<!-- 文件不存在则激活profile -->
<missing>/usr/local/min/workspace</missing>
</file>
</activation>
<!-- 远程仓库列表,是maven用来填充构建系统本地仓库所使用的一组远程项目 -->
<repositories>
<!-- 远程仓库 -->
<repository>
<!-- 远程仓库唯一标识 -->
<id>jdk14</id>
<!-- 远程仓库名称 -->
<name>Repository for JDK 1.4 builds</name>
<!-- 远程仓库url -->
<url>http://www.myhost.com/maven/jdk14</url>
<!-- maven 2为仓库提供的默认布局,maven 1.x有另一个不同的布局,通过default/legacy指定 -->
<layout>default</layout>
<snapshotPolicy>always</snapshotPolicy>
</repository>
</repositories>
<!-- 插件远程仓库 -->
<pluginRepositories>
<pluginRepository> <pluginRepository>
</pluginRepositories>
<!--
对应profile的扩展属性列表,和ant中的属性一样,可以用来存放值,这些值可以在pom的任何地方使用${x}访问,x指代属性名称
<env.x>:返回shell环境变量
<project.x>:指代pom对应的元素值
<settings.x>:指代settings.xml中对应的元素值
<x>:在<properties/>中或外部文件中使用${x}形式使用
-->
<properties>
<var>value</var>
</properties>
</profile>
</profiles>
<!-- 手动激活的profile列表 -->
<activeProfiles>
<!-- 如果有匹配的profile则pom.xml或者profile.xml中对应id的profile被激活 -->
<activeProfile>value</activeProfile>
</activeProfiles>
</settings>
实际应用中,经常使用到的是<localRepository>,<servers>,<mirrors>,<profiles>几个节点
<localRepository>:配置本地仓库地址
<servers>:服务端配置,多用于鉴权操作
<mirrors>:镜像配置,如使用阿里云镜像
<profiles>:系统构建配置,涉及整个系统的构建,可以让maven自动适应外部环境的变化
主要元素有:激活<activation>,仓库<repositories>,插件仓库<pluginRepositories>,属性<properties>
一个项目可以设置多个profile,也可以在同一时间设置多个profile被激活
自动激活条件主要有:操作系统相关参数的判断,JDK版本的检查,属性值的检查,文件检查
如果settings.xml中的profile被激活,则其值会覆盖pom.xml或profile.xml中同等id的profile
maven - settings.xml文件详解的更多相关文章
- Maven pom.xml文件详解
Maven pom.xml文件详解 一.简介 POM全称是Project Object Model,即项目对象模型. pom.xml是maven的项目描述文件,它类似与antx的project.xml ...
- 【maven学习】settings.xml文件详解
环境 apache-maven-3.6.1 jdk 1.8 eclipse 4.7 Settings.xml是设置maven参数的配置文件,包含类似本地仓储位置.修改远程仓储服务器.认证信息等配置.p ...
- 学习笔记——Maven settings.xml 配置详解
文件存放位置 全局配置: ${M2_HOME}/conf/settings.xml 用户配置: ${user.home}/.m2/settings.xml note:用户配置优先于全局配置.${use ...
- [maven] pom.xml 文件详解
参考资料: http://blog.csdn.net/uohzoaix/article/details/7035307 http://www.cnblogs.com/qq78292959/p/3711 ...
- Maven setting.xml文件详解(转)
maven的配置文件settings.xml存在于两个地方: 1.安装的地方:${M2_HOME}/conf/settings.xml 2.用户的目录:${user.home}/.m2/setting ...
- Maven settings.xml配置详解
首先:Maven中央仓库的搜索全部公共jar包的地址是,http://search.maven.org/ ===Maven基础-默认中央仓库============================== ...
- 史上最全的maven的pom.xml文件详解(转载)
此文出处:史上最全的maven的pom.xml文件详解——阿豪聊干货 <project xmlns="http://maven.apache.org/POM/4.0.0" x ...
- Maven的settings.xml配置详解
子节点详细介绍转载:http://www.cnblogs.com/jingmoxukong/p/6050172.html?utm_source=gold_browser_extension 全局配置 ...
- [转]Maven的pom.xml文件详解
Maven的pom.xml文件详解------Build Settings 2013年10月30日 13:04:01 阅读数:44678 根据POM 4.0.0 XSD,build元素概念性的划分为两 ...
随机推荐
- cocos2d-js v3新特性
1.游戏对象 使用cc.game单例代替了原有的cc.Application以及cc.AppControl 2.属性风格API 旧的API ...
- android DownloadManager.getInputStream返回null的一种情况
将下载操作的代码放到一个新的子线程中来执行.
- ssh key 生成
1.设置好git的name和email $ git config --global user.name "姓名" $ git config --global user.email ...
- windows搭建FTP服务器实战
第一步:创建用户名密码(ftp使用) 1.1.点击“开始”菜单,选择“控制面板”. 1.2.选择“管理工具”—>“计算机管理” 1.3. 选择“本地用户和组”下的用户,右键选择“新用户” 输入用 ...
- Unity编译时找不到AndroidSDK的问题 | Unable to list target platforms
解决方式 1.从官网下载一个旧版本的 Android SDK tools 25.2.3.tools_r25.2.3-windows.zip. 2. 解压 3. 替换原来sdk目录下tools
- guava cache与spring集成
缓存的背景 缓存,在我们日常开发中是必不可少的一种解决性能问题的方法.简单的说,cache 就是为了提升系统性能而开辟的一块内存空间.在cpu进行计算的时候, 首先是读取寄存器,然后内存,再是硬盘.由 ...
- Codeforces Round #364 (Div. 1)(vp) 没什么题解就留坑待填
我就做了前两题,第一题第一次vp就把我搞自闭跑路了,第二题第二次又把我搞自闭了 A. As Fast As Possible 细节题 #include<cstdio> #include&l ...
- CSU - 1547 Rectangle —— DP(01背包)
题目链接:http://acm.csu.edu.cn/csuoj/problemset/problem?pid=1547 题解: 关键是怎么处理长度为1的长方形.当长度为1的长方形的个数cnt> ...
- linux从用户组中删除某用户
1. 从wheel组中删除 test用户 gpasswd wheel -d test 2. 给 目录赋予 其他组上传文件的权限 chmod a+w test
- ffmpeg 中av_rescale_rnd 的含义
http://blog.csdn.net/fireroll/article/details/8485482 一.函数声明: int64_t av_rescale_rnd(int64_t a, int6 ...