maven环境搭建:

    1.官网下载zip包,解压至任意目录(如:E:\wly\apache-maven-3.2.5)
    2.环境变量MAVEN_HOME(E:\wly\apache-maven-3.2.5)、path追加"%MAVEN_HOME%\bin;"
    3.cmd命令行mvn -v,正常输出maven版本代表OK

  settings.xml详解:

  操作setting.xml之前,先了解一下maven是基于用户的。默认全局的配置文件"maven安装目录/conf/settings.xml",可以拷贝"settings.xml"放到"用户目录/.m2"/下,此时用户目录下的settings.xml会覆盖原配置。

  接下来我们看一下settings.xml中都能配置什么?下面内容以3.3.9版本为例:

  官方文档传送门:http://maven.apache.org/ref/3.3.9/maven-settings/settings.html

配置大纲:

localRepository     本地仓库,默认在用户/.m2/repository

interactiveMode     交互模式,默认为true
usePluginRegistry   是否使用plugin-registry.xml文件管理插件版本,默认为false offline        是否使用离线模式,默认为false proxies/proxy*    配置代理,通常给无法直接访问中央仓库的用户使用 servers/server*   服务器身份认证,比如当需要deploy一个包到远程仓库时,需要权限验证。此配置属于公用配置,且配置在pom.xml中不太安全,通常与<distributionManagement><id>匹配 mirrors/mirror*   镜像配置,会覆盖远程仓库配置 profiles/profile* 用于配置不同环境的差异文件 activeProfiles/activeProfile* 手动激活的默认差异文件 pluginGroups/pluginGroup* 当插件的groupId没有显式提供,从此插件的group中寻找需要的插件

详细配置说明:

代理(proxies/proxy*):

<proxies>
<proxy>
<!-- 代理标识 -->
<id>testProxy</id>
<!-- 是否激活,默认是true -->
<active>true</active>
<!-- 代理协议 -->
<protocol>http</protocol>
<!-- 用户名 -->
<username>wang</username>
<!-- 密码 -->
<password>123</password>
<!-- 端口 -->
<port>8099</port>
<!-- 主机 -->
<host>proxy.xxx.com</host>
<!-- 不需要代理的主机 -->
<nonProxyHosts>*.xx1.com|*.xx2.com</nonProxyHosts>
</proxy>
</proxies>

服务器认证(servers/server*):支持用户名/密码,公钥/私钥两种认证方式

<servers>
<server>
<!-- 服务标识 -->
<id>server1</id>
<!-- 用户名 -->
<username>wang</username>
<!-- 密码 -->
<password>123</password>
</server>
<server>
<id>server2</id>
<privateKey>wang</username>
<passphrase>456</passphrase>
</server>
</servers>

镜像(mirrors/mirror*):用<mirrorOf>配置覆盖一个或者多个仓库的配置。

<mirrorOf>元素:

  * = everything

  external:* = everything not on the localhost and not file based.

  repo,repo1 = repo or repo1

  *,!repo1 = everything except repo1

优点:1.速度快 2.使用自定义镜像可管控

<mirrors>
<mirror>
<!-- 镜像id,唯一标识 -->
<id>central-mirror</id>
<!-- 镜像名称 -->
<name>Maven China Mirror</name>
<!-- 镜像地址 -->
<url>http://search.maven.org/#browse</url>
<!-- 这个是谁的镜像,覆盖哪个仓库的配置 -->
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>

环境差异文件(profiles/profile*):

<profiles>
<!--通过某些条件匹配来激活不同<profile>,如jdk、os、属性和属性值等等-->
<profile>
<!-- 唯一标识id -->
<id>jdk-1.6</id>
<!-- 激活条件 -->
<activation>
<jdk>1.6</jdk>
</activation>
<!-- 键值对属性 -->
<properties>
<property.key>property.value</property.key>
         <!--
            maven支持使用占位符的方式设置或获取值
            1.env:操作系统环境变量
            2.project.x:当前project的属性
            3.setttings.x:对应settings.xml文件的属性
            4.properties文件中的属性(redis.ip=10.11.12.13):redis.ip
            5.x:<properties>中设置的属性
          -->
                <anykey>${env.path}</anykey>
</properties>
            <!-- 仓库配置 -->
<repositories>
<repository>
<id>仓库id</id>
<name>仓库名称</name>
<url>仓库url</url>
<layout>在Maven 2/3中都是default,只有在Maven 1.x中才是legacy,默认也是default</layout>
<!-- 发布的稳定版本 -->
<releases>
<checksumPolicy>当组件校验失败时,warn或fail</checksumPolicy>
<enabled>是否使用此库下载组件</enabled>
<updatePolicy>当组件在本地不存在时的更新策略:always、daily(default)、interval:xx(in minutes)、never</updatePolicy>
</releases>
<!-- 快照版本,注释同上 -->
<snapshots>
<checksumPolicy></checksumPolicy>
<enabled></enabled>
<updatePolicy></updatePolicy>
</snapshots>
</repository>
</repositories>
<!-- 插件仓库 -->
<pluginRepositories>
<pluginRepository>
<!-- 配置与repository类似 -->
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>

激活某个差异文件(activeProfiles/activeProfile*):

<!-- 指定某个profile生效 -->
<activeProfiles>
<activeProfile>对应profile id</activeProfile>
</activeProfiles>

当插件groupId没有显示提供,使用此groupId进行查找(pluginGroups/pluginGroup*):

<pluginGroups>
<!-- 当插件groupId没有显示提供,使用此groupId查找插件 -->
<!-- 官网:(Many) List of groupIds to search for a plugin when that plugin groupId is not explicitly provided. -->
<pluginGroup>org.mortbay.jetty</pluginGroup>
<pluginGroup>org.codehaus.cargo</pluginGroup>
</pluginGroups>

maven学习(一)setting.xml配置文件详解的更多相关文章

  1. 【maven学习】pom.xml文件详解

    环境 apache-maven-3.6.1 jdk 1.8 eclipse 4.7 POM是项目对象模型(Project Object Model)的简称,它是Maven项目中的文件,使用XML表示, ...

  2. Maven之(六)setting.xml配置文件详解

    setting.xml配置文件 maven的配置文件settings.xml存在于两个地方: 1.安装的地方:${M2_HOME}/conf/settings.xml 2.用户的目录:${user.h ...

  3. Maven之setting.xml配置文件详解

    setting.xml配置文件 maven的配置文件settings.xml存在于两个地方: 1.安装的地方:${M2_HOME}/conf/settings.xml 2.用户的目录:${user.h ...

  4. 【maven学习】settings.xml文件详解

    环境 apache-maven-3.6.1 jdk 1.8 eclipse 4.7 Settings.xml是设置maven参数的配置文件,包含类似本地仓储位置.修改远程仓储服务器.认证信息等配置.p ...

  5. Maven系列二setting.xml 配置详解

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

  6. Maven中的pom.xml配置文件详解

    原文:http://blog.csdn.net/u012152619/article/details/51485297 <project xmlns="http://maven.apa ...

  7. 6.Maven之(六)setting.xml配置文件详解

    转自:https://blog.csdn.net/u012152619/article/details/51485152

  8. Java数据持久层框架 MyBatis之API学习四(xml配置文件详解)

    摘录网址: http://blog.csdn.net/u010107350/article/details/51292500 对于MyBatis的学习而言,最好去MyBatis的官方文档:http:/ ...

  9. struts2学习笔记--struts.xml配置文件详解

    这一节主要讲解struts2里面的struts.xml的常用标签及作用: 解决乱码问题 <constant name="struts.i18n.encoding" value ...

随机推荐

  1. EasyUI学习笔记(一)EasyUI入门

    一.EasyUI下载 EasyUI官方下载地址:http://www.jeasyui.com/download/index.php,目前最新的版本是:jquery-easyui-1.7.2 解压后得到 ...

  2. Macaca,Maven,MVC框架

    Macaca:Macaca是阿里开源的一套完整的自动化测试解决方案.同时支持PC和移动端测试,支持的语言有JS,Java,Python. Maven:java,Maven项目对象模型(POM),可以通 ...

  3. Win7电脑开机无法正常启动只能进入安全模式解决方式

    我们先尝试在开机的时候按F8进入安全模式,进入到安全模式后一次打开“控制面板”-“程序与功能”,然后将卡巴斯基卸载[ http://jingyan.baidu.com/article/ff42efa9 ...

  4. Intelligent Poetry

    Readme: Creat poems. import re import random from collections import Counter def Creat_Poem(number): ...

  5. 【AC自动机】【字符串】【字典树】AC自动机 学习笔记

    blog:www.wjyyy.top     AC自动机是一种毒瘤的方便的多模式串匹配算法.基于字典树,用到了类似KMP的思维.     AC自动机与KMP不同的是,AC自动机可以同时匹配多个模式串, ...

  6. SPOJ - REPEATS RMQ循环节

    题意:求重复次数最多的重复子串(并非长度最长) 枚举循环子串长度\(L\),求最多能连续出现多少次,相邻的节点往后的判断可以使用\(LCP\)得到值为\(K\),那么得到一个可能的解就是\(K/L+1 ...

  7. Qt客户端阿里云服上传文件

    整体原理: 阿里云提供了c程序上传文件到阿里云服务器的sdk工具包,将这个工具包继承在自己的客户端,调用接口即可实现上传文件. 前期准备: 1.阿里云c程序客户端的sdk,下载地址:https://h ...

  8. jdk8涉及到的接口、类及方法

    bi是binary的简写,二元的,表示两个参数 unary,一元的,表示一个参数 1.函数式接口Supplier T get(),不接收参数,有返回值 IntSupplier,int getAsInt ...

  9. 将libFM模型变换成tensorflow可serving的形式

    fm_model是libFM生成的模型 model.ckpt是可以tensorflow serving的模型结构 亲测输出正确. 代码: import tensorflow as tf # libFM ...

  10. (转)Linux磁盘空间监控告警 && Linux磁盘管理

    Linux磁盘空间监控告警 http://blog.csdn.net/github_39069288/article/details/73478784-----------Linux磁盘管理 原文:h ...