Maven3.8.*系列 settings.xml详解

阿里云国内75折 回扣 微信号:monov8
阿里云国际,腾讯云国际,低至75折。AWS 93折 免费开户实名账号 代冲值 优惠多多 微信号:monov8 飞机:@monov6

文末,拿完整Settings配置文件

设置参考

介绍

在这里插入图片描述

简要概述

settings 元素 settings.xml 文件中包含的元素 定义价值观念配置家执行各种方式就像 的 pom.xml 但不应该被捆绑的任何具体项目或 分布到一个观众。 这些包括价值观如地方 仓库位置、替代的远程数据库服务器 身份验证的信息。

有两个位置 settings.xml 文件可能的生活

  • 该专家安装 ${maven.home}/conf/settings.xml
  • 一个用户的安装 ${user.home}/.m2/settings.xml

settings.xml 也被称为全球设置上后者 settings.xml 被称为用户设置。 如果这两个文件存在 它们的内容得到合并与特定用户 settings.xml正在 占主导地位。

提示如果需要建立用户特定的的设置从头开始的它的 最简单的复制的全球设置自己的专家安装到你的 ${user.home}/.m2 目录。 专家就是默认 settings.xml 是一个 模板的意见和例子所以你可以迅速地调整它对匹配 您的需求。

这里是概述的顶元下 settings:

        <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 https://maven.apache.org/xsd/settings-1.0.0.xsd">
          <localRepository/>
          <interactiveMode/>
          <offline/>
          <pluginGroups/>
          <servers/>
          <mirrors/>
          <proxies/>
          <profiles/>
          <activeProfiles/>
        </settings>

的内容 settings.xml 可以插使用 下面的表达方式

  1. ${user.home} 和所有其他系统属性 (因为家3.0)
  2. ${env.HOME} 等等。 对于环境变量

注意定义的属性文件之内 settings.xml 不能用于插。

设置详细信息

简单的价值观

一半的顶级 settings 元素是简单的价值 代表一个范围值描述元素的生成 系统活动的全时间。

    <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 https://maven.apache.org/xsd/settings-1.0.0.xsd">
      <localRepository>${user.home}/.m2/repository</localRepository>
      <interactiveMode>true</interactiveMode>
      <offline>false</offline>
      ...
    </settings>
  • localRepository 此值是的道路这建立的系统 当地的存储库。 默认值 ${user.home}/.m2/repository. 这个元件是特别有用 一个主要建立服务器允许所有已登录在用户建立从 公共当地的存储库。
  • interactiveMode : true 如果家应该试图与 用户输入 false 如果没有。 默 true.
  • 线下 : true 如果这个建立系统运作应在离线 模式默认 false. 这个元素是用于建立服务器 无法连接到一个远程信息库要么是因为 网络建立或安全的原因。

插件组

这种元素包含有一个列表中的 pluginGroup 元件每个都包含一个 组标识. 该清单是搜索时的一个插件是用于和组标识是 未提供在命令行。 这个清单包含自动 org.apache.maven.pluginsorg.codehaus.mojo.

    <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 https://maven.apache.org/xsd/settings-1.0.0.xsd">
      ...
      <pluginGroups>
        <pluginGroup>org.eclipse.jetty</pluginGroup>
      </pluginGroups>
      ...
    </settings>

例如鉴于上述设置的家命令行可以执行 org.eclipse.jetty:jetty-maven-plugin:run 与截命令

mvn jetty:run

服务器

库下载和部署的定义 repositoriesdistributionManagement元素 的POM。 然而某些环境如 usernamepassword 不应该分发 pom.xml. 这种类型的 信息应该存在于建立服务器 settings.xml.

    <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 https://maven.apache.org/xsd/settings-1.0.0.xsd">
      ...
      <servers>
        <server>
          <id>server001</id>
          <username>my_login</username>
          <password>my_password</password>
          <privateKey>${user.home}/.ssh/id_dsa</privateKey>
          <passphrase>some_passphrase</passphrase>
          <filePermissions>664</filePermissions>
          <directoryPermissions>775</directoryPermissions>
          <configuration></configuration>
        </server>
      </servers>
      ...
    </settings>
  • id :这是身份证的服务器 (不用户登录) 相匹配的 id 元件的储存库/镜的家 尝试连接。
  • username , 密码 这些要素表现为对表示 登录名和密码需要进行身份验证以此服务器。
  • 私钥 , 密码 像前面的两个要素这个 对指定一个路径的私人钥匙(默认是 ${user.home}/.ssh/id_dsa)和一个 passphrase 如果需要。 的 passphrasepassword 元素可能是在外部化 未来但现在他们必须设置的纯文本中的 settings.xml 文件。
  • filePermissions , directoryPermissions 当一个仓库 文件或录是建立在部署这些都是的 权限的使用。 该法律价值的每个是一个三位号码 对应于*nix权限文件例如664或775.

如果使用一个私人钥匙要登录服务器确保你 省略 <password> 元素。 否则关键将会被忽略。

密码加密的

一个新的功能服务器的密码和密码加密已经加入 2.1.0包括以+. 详情请参阅 上这个 页面

镜像

    <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 https://maven.apache.org/xsd/settings-1.0.0.xsd">
      ...
      <mirrors>
        <mirror>
          <id>planetmirror.com</id>
          <name>PlanetMirror Australia</name>
          <url>http://downloads.planetmirror.com/pub/maven2</url>
          <mirrorOf>central</mirrorOf>
        </mirror>
      </mirrors>
      ...
    </settings>
  • id , name :唯一的标识符和用户友好的名字 这面镜子。 的 id 是用来区分 mirror 元素和选择相应的证书 `` 部分时连接的反射镜。
  • url :基URL的这面镜子。 在建立系统将使用这个 URL连接到一个储存库而不是原来的仓库 网址。
  • mirrorOf id 储存库这是一面镜子。 例如来指向一个镜子的家 central库 ( https://repo.maven.apache.org/maven2/)设置这个元素 central. 更先进的映像 repo1,repo2*,!inhouse 也是可能的。 这必须不匹配镜 id.

为了更深入的介绍请阅读 指南 镜设置 .

代理

    <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 https://maven.apache.org/xsd/settings-1.0.0.xsd">
      ...
      <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>
      ...
    </settings>
  • id :独特的标识为这一代理。 这是用来 之间的区别 proxy 元素。
  • 活动 : true 如果该代理活动的。 这是有用的 宣布设的代理人但只有一个可以活跃的时间。
  • 协议 , host , port protocol://host:port 的 代理分为离散的要素。
  • username , 密码 这些要素表现为对表示 登录名和密码需要进行身份验证以此代理 服务器。
  • nonProxyHosts 这是一个列表的主持这不应该 代理。 分隔的清单是预期类型的代理 服务器上述例子是管分隔的逗号分隔的是 也很常见。

配置文件

profile 元素 settings.xml 是截版本的 的 pom.xml profile 元素。 它由 activation, repositories, pluginRepositoriesproperties 元素。 的 profile 元只包括这四个要素因为它们 关注自己与建立系统作为一个整体(其中的作用 的 settings.xml 文件)而不是单个项目对象模型 设置。

如果一个配置文件活动 settings其价值将复盖的任何 等效地ID会档案在一个或POM profiles.xml 文件。

激活

激活的关键。 喜欢POM的档案电 配置文件来自其能力以修改某些价值仅下 某些情况下这些情况下被指定的通过 activation 元素。

    <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 https://maven.apache.org/xsd/settings-1.0.0.xsd">
      ...
      <profiles>
        <profile>
          <id>test</id>
          <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>
          ...
        </profile>
      </profiles>
      ...
    </settings>

激活发生时的所有规定的条件已得到满足虽然不是 所有的都需要一次。

  • java : activation 有一个内置、Java为中心的检查 jdk 元素。 这将激活如果试验是在一个java 版本号相匹配的前缀定。 在上述例子中 1.5.0_06 将匹配。 范围也支持。 看看 家实施者-插件 有关的更多详细信息支持的范围。
  • os os 元素可以定义的一些特定的操作系统 性上所示。 看看 家实施者-插件 更多的细节约OS值。
  • 财产 profile 将激活如果家检测 财产(价值它可以引用内通过POM ${name})的相应的 name=value 对。
  • 文件 最后鉴于文件可能激活 profile通过 的 existence 一个文件或者如果它是 missing.

activation 元素不是唯一的方法 profile 可 激活。 的 settings.xml 文件的 activeProfile 元素可能包含 配置文件 id. 他们还可以激活的明确的通过 命令行通过一个逗号分开后 -P 标志(例如 -P test).

看看它的配置文件将激活在一定的建立使用 maven-help-plugin.

mvn help:active-profiles

性能

家属性是值符样性在蚂蚁。 他们 值是任何地方访问内POM通过使用标记符号 ${X}哪里 X 是的财产。 他们在五个不同的样式 所有访问 settings.xml 文件

  1. env.X:前缀的一个变量与环境。 将返回外壳的 环境变量。 例如 ${env.PATH} 包含美元的路径 环境变量( %PATH% 在Windows)。
  2. project.x一个点(.) 称路径POM中将包含 相应的元素的价值。 例如 <project><version>1.0</version></project> 可通过 ${project.version}.
  3. settings.x一个点(.) 声明中的路径 settings.xml将 含有相应的元素的价值。 例如 <settings><offline>false</offline></settings> 可通过 ${settings.offline}.
  4. Java系统的特性所有特性可通过 java.lang.System.getProperties() 都可以作为POM性 如 ${java.home}.
  5. x设置在<性元素或外部文件 价值也可用作 ${someVar}.
    <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 https://maven.apache.org/xsd/settings-1.0.0.xsd">
      ...
      <profiles>
        <profile>
          ...
          <properties>
            <user.install>${user.home}/our-project</user.install>
          </properties>
          ...
        </profile>
      </profiles>
      ...
    </settings>

酒店 ${user.install} 可从一个POM如果这种档 是活动的。

库遥集的项目从其家使用 填充地储存库的建立系统。 正是从这个地方 仓库专家呼吁它插件和依赖关系。 不同的 远程存储库可以包含不同的项目并在活动 配置文件他们可以寻找匹配的释放或快照 神器。

    <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 https://maven.apache.org/xsd/settings-1.0.0.xsd">
      ...
      <profiles>
        <profile>
          ...
          <repositories>
            <repository>
              <id>codehausSnapshots</id>
              <name>Codehaus Snapshots</name>
              <releases>
                <enabled>false</enabled>
                <updatePolicy>always</updatePolicy>
                <checksumPolicy>warn</checksumPolicy>
              </releases>
              <snapshots>
                <enabled>true</enabled>
                <updatePolicy>never</updatePolicy>
                <checksumPolicy>fail</checksumPolicy>
              </snapshots>
              <url>http://snapshots.maven.codehaus.org/maven2</url>
              <layout>default</layout>
            </repository>
          </repositories>
          <pluginRepositories>
            <pluginRepository>
              <id>myPluginRepo</id>
              <name>My Plugins repo</name>
              <releases>
                <enabled>true</enabled>
              </releases>
              <snapshots>
                <enabled>false</enabled>
              </snapshots>
              <url>https://maven-central-eu....com/maven2/</url>
            </pluginRepository>
          </pluginRepositories>
          ...
        </profile>
      </profiles>
      ...
    </settings>
 
  • 释放 , 快照 这些政策对于每个类型的 神器、释放或快照。 与这两组一个有POM 力量改变的政策为每种类型的独立的其他 在一个单一的储存库。 例如一个可能决定启用 只有快照下载也可能用于发展目的。
  • 启用 : truefalse 对于这是否存储库 启用各自的类型( releasessnapshots).
  • updatePolicy 这元指定经常更新应 尝试的发生。 专家会比较本地球的时间戳 (存储在一个仓库的家元数据文件)的远程。 的 选择是 always, daily (默认) interval:X (其中X是 整数分钟)或 never.
  • checksumPolicy 当家部署的文件的储存库 还部署了相应的验和文件。 你的选择是 ignore, failwarn 在缺失或不正确的校验和。
  • 布局 在上述说明的储存库这是 提到他们都遵循一个共同的布局。 这主要是 正确的。 玛文2有一个默认的布局为其仓库中但是 玛文1中。x有一个不同的布局。 使用这元来指定哪 如果它是 defaultlegacy.

插件的储存库

仓库里的两个主要类型的文物。 第一是 文物被用作依赖关系的其他项目。 这些都是 大部分的文物存在于中央。 其他类型的 神器被插件。 家插件本身就是一种特殊类型的 神器。 因此插件的储存库可能被分离 其它储存库(虽然我还没有听到一个令人信服的论点 这样做). 在任何情况下结构 pluginRepositories 元块是类似于 repositories 元素。 的 pluginRepository 元素中的每一个指定一个遥远的位置在哪里 专家可以找到新的插件。

活动概况

     <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 https://maven.apache.org/xsd/settings-1.0.0.xsd">
      ...
      <activeProfiles>
        <activeProfile>env-test</activeProfile>
      </activeProfiles>
    </settings>

最后一块 settings.xml 拼图的 activeProfiles 元素。 这包含一套 activeProfile 元素其中每 有价值的 profile id. 任何 profile id 定义为 activeProfile 将活动而不管任何环境中设置。 如果没有匹配的配置找到了什么都不会发生。 例如如果 env-test 是一个 activeProfile 一个人资料 pom.xml(或 profile.xml 与相应的 id 将活动。 如果没有这样 配置文件被发现后的执行将继续作为正常的。

直达文末,拿完整Settings配置文件


<?xml version="1.0" encoding="UTF-8"?>

<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License.  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License.
-->

<!--
 | This is the configuration file for Maven. It can be specified at two levels:
 |
 |  1. User Level. This settings.xml file provides configuration for a single user,
 |                 and is normally provided in ${user.home}/.m2/settings.xml.
 |
 |                 NOTE: This location can be overridden with the CLI option:
 |
 |                 -s /path/to/user/settings.xml
 |
 |  2. Global Level. This settings.xml file provides configuration for all Maven
 |                 users on a machine (assuming they're all using the same Maven
 |                 installation). It's normally provided in
 |                 ${maven.conf}/settings.xml.
 |
 |                 NOTE: This location can be overridden with the CLI option:
 |
 |                 -gs /path/to/global/settings.xml
 |
 | The sections in this sample file are intended to give you a running start at
 | getting the most out of your Maven installation. Where appropriate, the default
 | values (values used when the setting is not specified) are provided.
 |
 |-->
<settings xmlns="http://maven.apache.org/SETTINGS/1.2.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.2.0 https://maven.apache.org/xsd/settings-1.2.0.xsd">
  <!-- localRepository
   | The path to the local repository maven will use to store artifacts.
   |
   | Default: ${user.home}/.m2/repository
  <localRepository>/path/to/local/repo</localRepository>
  本地仓库位置,改为自己的目录即可
  -->
<localRepository>D:/Java/MavenRepository/</localRepository>
  <!-- interactiveMode
   | This will determine whether maven prompts you when it needs input. If set to false,
   | maven will use a sensible default value, perhaps based on some other setting, for
   | the parameter in question.
   |
   | Default: true
  <interactiveMode>true</interactiveMode>
  -->

  <!-- offline
   | Determines whether maven should attempt to connect to the network when executing a build.
   | This will have an effect on artifact downloads, artifact deployment, and others.
   |
   | Default: false
  <offline>false</offline>
  -->

  <!-- pluginGroups
   | This is a list of additional group identifiers that will be searched when resolving plugins by their prefix, i.e.
   | when invoking a command line like "mvn prefix:goal". Maven will automatically add the group identifiers
   | "org.apache.maven.plugins" and "org.codehaus.mojo" if these are not already contained in the list.
   |-->
  <pluginGroups>
    <!-- pluginGroup
     | Specifies a further group identifier to use for plugin lookup.
    <pluginGroup>com.your.plugins</pluginGroup>
    -->
  </pluginGroups>

  <!-- proxies
   | This is a list of proxies which can be used on this machine to connect to the network.
   | Unless otherwise specified (by system property or command-line switch), the first proxy
   | specification in this list marked as active will be used.
   |-->
  <proxies>
    <!-- proxy
     | Specification for one proxy, to be used in connecting to the network.
     |
    <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>

  <!-- servers
   | This is a list of authentication profiles, keyed by the server-id used within the system.
   | Authentication profiles can be used whenever maven must make a connection to a remote server.
   |-->
  <servers>
    <!-- server
     | Specifies the authentication information to use when connecting to a particular server, identified by
     | a unique name within the system (referred to by the 'id' attribute below).
     |
     | NOTE: You should either specify username/password OR privateKey/passphrase, since these pairings are
     |       used together.
     |
    <server>
      <id>deploymentRepo</id>
      <username>repouser</username>
      <password>repopwd</password>
    </server>
    -->

    <!-- Another sample, using keys to authenticate.
    <server>
      <id>siteServer</id>
      <privateKey>/path/to/private/key</privateKey>
      <passphrase>optional; leave empty if not used.</passphrase>
    </server>
    -->
  </servers>

  <!-- mirrors
   | This is a list of mirrors to be used in downloading artifacts from remote repositories.
   |
   | It works like this: a POM may declare a repository to use in resolving certain artifacts.
   | However, this repository may have problems with heavy traffic at times, so people have mirrored
   | it to several places.
   |
   | That repository definition will have a unique id, so we can create a mirror reference for that
   | repository, to be used as an alternate download site. The mirror site will be the preferred
   | server for that repository.
   |-->
  <mirrors>
    <!-- mirror
     | Specifies a repository mirror site to use instead of a given repository. The repository that
     | this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
     | for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
     |
    <mirror>
      <id>mirrorId</id>
      <mirrorOf>repositoryId</mirrorOf>
      <name>Human Readable Name for this Mirror.</name>
      <url>http://my.repository.com/repo/path</url>
    </mirror>
     -->
    <mirror>
      <id>maven-default-http-blocker</id>
      <mirrorOf>external:http:*</mirrorOf>
      <name>Pseudo repository to mirror external repositories initially using HTTP.</name>
      <url>http://0.0.0.0/</url>
      <blocked>true</blocked>
    </mirror>
<mirror>
        <id>aliyun-public</id>
        <mirrorOf>central</mirrorOf>
        <name>aliyun public</name>
        <url>https://maven.aliyun.com/repository/public</url>
    </mirror>

    <mirror>
        <id>aliyun-central</id>
        <mirrorOf>central</mirrorOf>
        <name>aliyun central</name>
        <url>https://maven.aliyun.com/repository/central</url>
    </mirror>
<!--
其中千万要切记一点mirrorOf 里面千万不能配置*号如果不配置 * 假设aliyun maven没有的话就会去国外仓库下载如果配置了 *号 
那阿里云仓库没有就会报错《mirrorOf>central</mirrorOf》 表示 凡是 central 仓库的包由阿里云url下载至于有哪些仓库

-->
    <mirror>
        <id>aliyun-spring</id>
        <mirrorOf>central</mirrorOf>
        <name>aliyun spring</name>
        <url>https://maven.aliyun.com/repository/spring</url>
    </mirror>

    <mirror>
        <id>aliyun-spring-plugin</id>
        <mirrorOf>central</mirrorOf>
        <name>aliyun spring-plugin</name>
        <url>https://maven.aliyun.com/repository/spring-plugin</url>
    </mirror>

    <mirror>
        <id>aliyun-apache-snapshots</id>
        <mirrorOf>central</mirrorOf>
        <name>aliyun apache-snapshots</name>
        <url>https://maven.aliyun.com/repository/apache-snapshots</url>
    </mirror>

    <mirror>
        <id>aliyun-google</id>
        <mirrorOf>central</mirrorOf>
        <name>aliyun google</name>
        <url>https://maven.aliyun.com/repository/google</url>
    </mirror>

    <mirror>
        <id>aliyun-gradle-plugin</id>
        <mirrorOf>central</mirrorOf>
        <name>aliyun gradle-plugin</name>
        <url>https://maven.aliyun.com/repository/gradle-plugin</url>
    </mirror>

    <mirror>
        <id>aliyun-jcenter</id>
        <mirrorOf>central</mirrorOf>
        <name>aliyun jcenter</name>
        <url>https://maven.aliyun.com/repository/jcenter</url>
    </mirror>

    <mirror>
        <id>aliyun-releases</id>
        <mirrorOf>central</mirrorOf>
        <name>aliyun releases</name>
        <url>https://maven.aliyun.com/repository/releases</url>
    </mirror>

    <mirror>
        <id>aliyun-snapshots</id>
        <mirrorOf>central</mirrorOf>
        <name>aliyun snapshots</name>
        <url>https://maven.aliyun.com/repository/snapshots</url>
    </mirror>

    <mirror>
        <id>aliyun-grails-core</id>
        <mirrorOf>central</mirrorOf>
        <name>aliyun grails-core</name>
        <url>https://maven.aliyun.com/repository/grails-core</url>
    </mirror>

    <mirror>
        <id>aliyun-mapr-public</id>
        <mirrorOf>central</mirrorOf>
        <name>aliyun mapr-public</name>
        <url>https://maven.aliyun.com/repository/mapr-public</url>
    </mirror>



  </mirrors>

  <!-- profiles
   | This is a list of profiles which can be activated in a variety of ways, and which can modify
   | the build process. Profiles provided in the settings.xml are intended to provide local machine-
   | specific paths and repository locations which allow the build to work in the local environment.
   |
   | For example, if you have an integration testing plugin - like cactus - that needs to know where
   | your Tomcat instance is installed, you can provide a variable here such that the variable is
   | dereferenced during the build process to configure the cactus plugin.
   |
   | As noted above, profiles can be activated in a variety of ways. One way - the activeProfiles
   | section of this document (settings.xml) - will be discussed later. Another way essentially
   | relies on the detection of a system property, either matching a particular value for the property,
   | or merely testing its existence. Profiles can also be activated by JDK version prefix, where a
   | value of '1.4' might activate a profile when the build is executed on a JDK version of '1.4.2_07'.
   | Finally, the list of active profiles can be specified directly from the command line.
   |
   | NOTE: For profiles defined in the settings.xml, you are restricted to specifying only artifact
   |       repositories, plugin repositories, and free-form properties to be used as configuration
   |       variables for plugins in the POM.
   |
   |-->
  <profiles>
    <!-- profile
     | Specifies a set of introductions to the build process, to be activated using one or more of the
     | mechanisms described above. For inheritance purposes, and to activate profiles via <activatedProfiles/>
     | or the command line, profiles have to have an ID that is unique.
     |
     | An encouraged best practice for profile identification is to use a consistent naming convention
     | for profiles, such as 'env-dev', 'env-test', 'env-production', 'user-jdcasey', 'user-brett', etc.
     | This will make it more intuitive to understand what the set of introduced profiles is attempting
     | to accomplish, particularly when you only have a list of profile id's for debug.
     |
     | This profile example uses the JDK version to trigger activation, and provides a JDK-specific repo.
    <profile>
      <id>jdk-1.4</id>

      <activation>
        <jdk>1.4</jdk>
      </activation>

      <repositories>
        <repository>
          <id>jdk14</id>
          <name>Repository for JDK 1.4 builds</name>
          <url>http://www.myhost.com/maven/jdk14</url>
          <layout>default</layout>
          <snapshotPolicy>always</snapshotPolicy>
        </repository>
      </repositories>
    </profile>
    -->

    <!--
     | Here is another profile, activated by the system property 'target-env' with a value of 'dev',
     | which provides a specific path to the Tomcat instance. To use this, your plugin configuration
     | might hypothetically look like:
     |
     | ...
     | <plugin>
     |   <groupId>org.myco.myplugins</groupId>
     |   <artifactId>myplugin</artifactId>
     |
     |   <configuration>
     |     <tomcatLocation>${tomcatPath}</tomcatLocation>
     |   </configuration>
     | </plugin>
     | ...
     |
     | NOTE: If you just wanted to inject this configuration whenever someone set 'target-env' to
     |       anything, you could just leave off the <value/> inside the activation-property.
     |
    <profile>
      <id>env-dev</id>

      <activation>
        <property>
          <name>target-env</name>
          <value>dev</value>
        </property>
      </activation>

      <properties>
        <tomcatPath>/path/to/tomcat/instance</tomcatPath>
      </properties>
    </profile>
    -->
  </profiles>

  <!-- activeProfiles
   | List of profiles that are active for all builds.
   |
  <activeProfiles>
    <activeProfile>alwaysActiveProfile</activeProfile>
    <activeProfile>anotherAlwaysActiveProfile</activeProfile>
  </activeProfiles>
  -->
</settings>





结语

如果这篇文章对您有所帮助或者有所启发的话求一键三连点赞、评论、收藏➕关注您的支持是我坚持写作最大的动力。

阿里云国内75折 回扣 微信号:monov8
阿里云国际,腾讯云国际,低至75折。AWS 93折 免费开户实名账号 代冲值 优惠多多 微信号:monov8 飞机:@monov6

“Maven3.8.*系列 settings.xml详解” 的相关文章