Maven 配置文件说明

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

This is the configuration file for Maven.
这是 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.
    settings.xml 文件为单个用户提供配置,通常在 ${user.home}/.m2/settings.xml
    NOTE: This location can be overridden with the CLI option:
    注意:可以使用 CLI 选项覆盖此位置:
    -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).
    settings.xml 文件为机器上的所有 Maven 用户提供配置(假设他们都使用相同的 Maven 安装)。
    It's normally provided in ${maven.conf}/settings.xml.
    通常在 ${maven.conf}/settings.xml
    NOTE: This location can be overridden with the CLI option:
    注意:可以使用 CLI 选项覆盖此位置:
    -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.
本示例文件中的部分旨在让您从 Maven 安装中获得最大收益。
Where appropriate, the default values (values used when the setting is not specified) are provided.
在适当的情况下,会提供默认值(未指定设置时使用的值)。


    
    
    
    
    
    
    
    
    

The path to the local repository maven will use to store artifacts.
Maven 用于存储工件(artifact)的本地仓库(repository)的路径。

Default: ${user.home}/.m2/repository

/path/to/local/repo

This will determine whether maven prompts you when it needs input.
这将决定 maven 是否在需要输入时提示您。
If set to false, maven will use a sensible default value, perhaps based on some other setting, for the parameter in question.
如果设置为 false,maven 将使用一个合理的默认值,可能是基于其他一些设置,用于询问中的参数。

Default: true

true

Determines whether maven should attempt to connect to the network when executing a build.
确定 maven 在执行构建时是否应尝试连接到网络。
This will have an effect on artifact downloads, artifact deployment, and others.
这将对工件下载、工件部署和其他方面产生影响。

Default: false

false

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".
这是一个附加组标识符的列表,当通过前缀解析插件时,即调用 "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.
如果列表中还没有包含组标识符 "org.apache.Maven.plugins" 和 "org.codehaus.mojo",Maven 将自动添加这些标识符。


    com.your.plugins

Specifies a further group identifier to use for plugin lookup.
指定用于插件查找的其他组标识符。

com.your.plugins

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.
除非另有规定(通过系统属性或命令行开关),否则将使用此列表中标记为活动的第一个代理规范。


    
      optional
      true
      http
      proxyuser
      proxypass
      proxy.host.net
      80
      local.net|some.host.com
    

Specification for one proxy, to be used in connecting to the network.
用于连接网络的一个代理的规范。


    optional
    true
    http
    proxyuser
    proxypass
    proxy.host.net
    80
    local.net|some.host.com

This is a list of authentication profiles, keyed by the server-id used within the system.
这是一个身份验证配置文件列表,由系统中使用的 server-id 设置密钥。
Authentication profiles can be used whenever maven must make a connection to a remote server.
只要 maven 必须连接到远程服务器,就可以使用身份验证配置文件。


    
      deploymentRepo
      repouser
      repopwd
    

    
    
      siteServer
      /path/to/private/key
      optional; leave empty if not used.
    
  

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).
该信息由系统中的唯一名称标识(由下面的 'id' 属性引用)。

NOTE: You should either specify username/password OR privateKey/passphrase, since these pairings are used together.
注意:您应该指定 username/passwordprivateKey/passphrase,因为这些配对是一起使用的。


    deploymentRepo
    repouser
    repopwd


    siteServer
    /path/to/private/key
    optional; leave empty if not used.

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.
它的工作原理是这样的:POM 可以声明一个用于解析某些工件的仓库。
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.
该仓库定义将有一个唯一的 id,因此我们可以为该仓库创建一个镜像引用,用作备用下载站点。
The mirror site will be the preferred server for that repository.
镜像站点将是该仓库的首选服务器。


    
        mirrorId
        repositoryId
        Human Readable Name for this Mirror.
        http://my.repository.com/repo/path
    
    
        alimaven
        aliyun maven
        http://maven.aliyun.com/nexus/content/groups/public/
        central
    

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.
此镜像服务的仓库的 ID 与此镜像的 mirrorOf 元素匹配。
IDs are used for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
ID 用于继承和直接查找目的,在镜像集中必须是唯一的。


    alimaven
    aliyun maven
    http://maven.aliyun.com/nexus/content/groups/public/
    central
    false

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.
settings.xml 中提供的配置信息旨在提供特定于本地机器的路径和存储库位置,以允许在本地环境中执行构建。

For example, if you have an integration testing plugin - like cactus - that needs to know where your Tomcat instance is installed,
例如,如果您有一个集成测试插件(比如 cactus),需要知道 Tomcat 实例的安装位置,
you can provide a variable here such that the variable is dereferenced during the build process to configure the cactus plugin.
那么您可以在这里提供一个变量,以便在构建过程中取消对该变量的引用,以配置 cactus 插件。

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.
其中一种方法——本文档的 activeProfiles 部分(settings.xml)——将在后面讨论。
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'.
配置信息也可以通过 JDK 版本前缀激活,其中当在 JDK 版本 '1.4.2_07' 上执行构建时,值 '1.4' 可能会激活配置信息。
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.
注意:对于在 settings.xml 中定义的配置信息,只能指定工件库、插件库和自由格式属性,以用作 POM 中插件的配置变量。


    
        ...
    

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 or the command line, profiles have to have an ID that is unique.
出于继承目的,要通过 或命令行激活配置信息,配置信息必须具有唯一的 ID。

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.
例如 'env-dev'、'env-test'、'env-production'、'user-jdcasey'、'user-brett' 等。
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.
尤其是当您只有一个用于调试的配置文件 id 列表时。

This profile example uses the JDK version to trigger activation, and provides a JDK-specific repo.
这个配置信息示例使用 JDK 版本触发激活,并提供了一个特定于 JDK 的 repo。


    jdk-1.4

    
        1.4
    

    
        
            jdk14
            Repository for JDK 1.4 builds
            http://www.myhost.com/maven/jdk14
            default
            always
        
    

Here is another profile, activated by the system property 'target-env' with a value of 'dev',
下面是另一个配置信息,由系统属性 'target-env' 激活,其值为'dev',
which provides a specific path to the Tomcat instance.
它提供了 Tomcat 实例的特定路径。
To use this, your plugin configuration might hypothetically look like:
要使用它,你的插件配置可能会假设如下:

...

    org.myco.myplugins
    myplugin

    
        ${tomcatPath}
    

...

NOTE: If you just wanted to inject this configuration whenever someone set 'target-env' to anything, you could just leave off the inside the activation-property.
注意:如果您只是想在有人将 'target-env' 设置为任何内容时注入此配置,您可以在 activation 属性中去掉


    env-dev

    
        
            target-env
            dev
        
    

    
        /path/to/tomcat/instance
    

List of profiles that are active for all builds.
对所有构件活动的配置文件列表。


    alwaysActiveProfile
    anotherAlwaysActiveProfile

附:settings.xml

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.
在一个或多个贡献者许可协议下授权给 Apache 软件基金会(ASF)。
See the NOTICE file distributed with this work for additional information regarding copyright ownership.
有关版权所有权的更多信息,请参阅随本文件一起分发的 NOTICE 文件。
The ASF licenses this file to you under the Apache License, Version 2.0 (the "License");
ASF 根据 Apache 许可证2.0版(下称“许可证”)向您许可该文件;
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.
请参阅许可证,以了解管理许可证下权限和限制的特定语言。







  

  

  

  
  
    
  

  
  
    
  

  
  
    

    
  

  
  
    
    
    
        alimaven
        aliyun maven
        http://maven.aliyun.com/nexus/content/groups/public/
        central
    
  

  
  
    

    
  

  

你可能感兴趣的:(Maven 配置文件说明)