一、简介

settings.xml对于maven来说相当于全局性的配置,用于所有的项目,

当Maven运行过程中的各种配置,例如pom.xml,不想绑定到一个固定的project或者要分配给用户时,

我们使用settings.xml中的settings元素来确定这些配置。

这包含了本地仓库位置,远程仓库服务器以及认证信息等。

settings.xml存在于两个地方:

1.安装的地方:$M2_HOME/conf/settings.xml

2.用户的目录:${user.home}/.m2/settings.xml

前者又被叫做全局配置,后者被称为用户配置。

如果两者都存在,它们的内容将被合并,并且用户范围的配置优先。

平时配置时优先选择用户目录的settings.xml

下面是settings下的顶层元素的一个概览:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<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">
    <localRepository/>
    <interactiveMode/>
    <usePluginRegistry/>
    <offline/>
    <pluginGroups/>
    <servers/>
    <mirrors/>
    <proxies/>
    <profiles/>
    <activeProfiles/>
</settings>

二、简单值

localRepository:这个值是构建系统的本地仓库的路径。默认的值是${user.home}/.m2/repository.如果一个系统想让所有登陆的用户都用同一个本地仓库的话,这个值是极其有用的。

interactiveMode:如果Maven要试图与用户交互来得到输入就设置为true,否则就设置为false,默认为true。

usePluginRegistry:如果Maven使用${user.home}/.m2/plugin-registry.xml来管理plugin的版本,就设置为true,默认为false。

offline:如果构建系统要在离线模式下工作,设置为true,默认为false。如果构建服务器因为网络故障或者安全问题不能与远程仓库相连,那么这个设置是非常有用的。

三、PluginGroups(插件组)

这个元素包含了一系列pluginGroup元素,每个又包含了一个groupId。当一个plugin被使用,而它的groupId没有被提供的时候,这个列表将被搜索。这个列表自动的包含了org.apache.maven.plugins和org.codehaus.mojo。

1
2
3
4
5
6
7
8
9
10
<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">
    ...
    <pluginGroups>
        <pluginGroup>org.mortbay.jetty</pluginGroup>
    </pluginGroups>
    ...
</settings>

四、Servers(服务器)

1. 定义jar包下载的Maven仓库

2. 定义部署服务器

1
2
3
4
5
6
7
8
9
10
11
12
<servers>
    <server>
        <id>tomcat</id>
        <username>bruce</username>
        <password>password</password>
    </server>
    <server>
        <id>shiyue</id>
        <username>admin</username>
        <password>password</password>
    </server>
  </servers>

tomcat: 部署服务器

shiyue: Mave私服

五、Mirrors(镜像)

指定仓库的地址,则默认从指定的镜像下载jar包及插件

1
2
3
4
5
6
7
8
9
<mirrors>
                                                                                                 
     <mirror>
      <id>mirrorId</id>
      <mirrorOf>*</mirrorOf>
      <name>Human Readable Name for this Mirror.</name>
      <url>http://host:port/nexus-2.1.2/content/groups/public</url>
    </mirror>
  </mirrors>

六、Proxies(代理)

有时候你所在的公司基于安全因素考虑,要求你使用通过安全认证的代理访问因特网。这时就需要为Maven配置HTTP代理。

1
2
3
4
5
6
7
8
9
10
11
12
<proxies>
    <proxy>
      <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>

参考:http://maven.apache.org/settings.html

maven入门(1-2)settings.xml的更多相关文章

  1. 详解Maven用户的配置settings.xml

    Maven用户设置 作者其他技术文章 1)Oracle性能优化之查询语句通用原则 2)Redis常用命令 3) SpringCloud入门之常用的配置文件 application.yml和 boots ...

  2. Maven的仓库和settings.xml配置文件

    (尊重劳动成果,转载请注明出处:https://blog.csdn.net/qq_25827845/article/details/83549846冷血之心的博客) 快速导航: Maven基础概念和安 ...

  3. 设置阿里云maven中央仓库的settings.xml

    本来想找一个可用的设置文件,结果乱七八糟的,干脆自己做了一个,同时还放上了Spring的SNAPSHOT和MILESTONE/RELEASE仓库,希望能帮到一些人. <?xml version= ...

  4. maven 配置篇 之 settings.xml

    maven2 比起maven1 来说,需要配置的文件少多了,主要集中在pom.xml和settings.xml中.    先来说说settings.xml,settings.xml对于maven来说相 ...

  5. maven command line specified settings.xml

    1. using argument parameter --settings  / or -s for shot mvn install --settings c:\user\settings.xml ...

  6. [JAVA] maven 阿里云节点 settings.xml

    <?xml version="1.0" encoding="UTF-8"?> <settings xmlns="http://mav ...

  7. Spring Tool Suite 使用自带maven速度慢---修改settings.xml更新mirror方法

    (1)打开sts,windows --> preference,找到maven,并设置如下. (2)修改该文件,如下 <mirror> <id>nexus-aliyun& ...

  8. maven设置------settings.xml文件学习

    https://blog.csdn.net/tomato__/article/details/13025187 快速预览 maven的配置文件为settings.xml,在下面路径中可以找到这个文件, ...

  9. maven - settings.xml文件详解

    Settings.xml配置文件详解 maven默认的settings.xml是一个包含注释和例子的模板,可以快速的修改settings.xml文件 maven安装后不会在用户目录下自动生成setti ...

  10. Taurus.MVC-Java 版本打包上传到Maven中央仓库(详细过程):3、Maven独立插件安装与settings.xml配置

    文章目录: Taurus.MVC-Java 版本打包上传到Maven中央仓库(详细过程):1.JIRA账号注册 Taurus.MVC-Java 版本打包上传到Maven中央仓库(详细过程):2.PGP ...

随机推荐

  1. Google Chrome Plus——绿色便携多功能谷歌浏览器

    我更新浏览器的时候一般没有时间更新这个帖子,所以具体请看我网盘下载链接里面的更新日志,请自行查看最新版本下载,谢谢. 近期更新日期:2016.8.15(此时间可能不是最新,请看我网盘里面的更新日志) ...

  2. 解决浏览器兼容ES6特性

    为什么ES6会有兼容性问题? 由于广大用户使用的浏览器版本在发布的时候也许早于ES6的定稿和发布,而到了今天,我们在编程中如果使用了ES6的新特性,浏览器若没有更新版本,或者新版本中没有对ES6的特性 ...

  3. Atlas安装配置

    准备环境 192.168.1.1(Altas) 192.168.1.2(MySQL主) 192.168.1.3(MySQL从) 官方链接:https://github.com/Qihoo360/Atl ...

  4. Problems at works

    1.ssh无法连接服务器:因部署ftp服务,误将/var目录的所有者和所属组改成了ftp,以致于SSH无法二次连接: 2.集群服务器的hadoop的datanode节点死亡,在对应节点拉起即可.若无法 ...

  5. DBI-1.634之selectrow_array与fetchrow_array的区别

    在DBI-1.634使用手册里有一个selectrow_array函数,该函数具体说明如下: This utility method combines "prepare", &qu ...

  6. 书写Css文件要点

    1. 自定义样式名 实例1:<style type="text/css"> input.ng-invalid{ // .号一定要在对应的元素名后面, 没有空格 colo ...

  7. poj-2909-哥德巴赫猜想

    Description For any even number n greater than or equal to 4, there exists at least one pair of prim ...

  8. 设计模式 --> (17)状态模式

    状态模式 允许一个对象在其内部状态改变时改变它的行为.对象看起来似乎修改了它的类.它有两种使用情况: (1)一个对象的行为取决于它的状态, 并且它必须在运行时刻根据状态改变它的行为. (2)一个操作中 ...

  9. StringBUffer和StringBuilder详解

    一.StringBUffer public  final  class  StringBUffer extends Object  implements Serializable,CharSequnc ...

  10. 安装Oracle客户端和plsql

    Oracle 客户端安装 +  pl/sql工具安装配置   Oracle 客户端安装 +  pl/sql工具安装配置 下载oracle客户端,并在本地安装. 11g下载地址为: http://www ...