Maven--settings.xml文件详细配置讲解--亲测

7 篇文章 0 订阅
3 篇文章 0 订阅

自己搭了一套maven私服库,配置自己的settings.xml,分享给大家

<?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.
   | 本地存储库maven的路径将用于存储工件。  
   | Default: ${user.home}/.m2/repository
  <localRepository>/path/to/local/repo</localRepository>
  -->
<localRepository>C:\aliyun\maven3.8.5\jar</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.
   | 这将决定maven在需要输入时是否会提示您。 如果设置为false,  
   | Maven将使用一个合理的默认值,可能基于其他一些设置  
   | 正在讨论的参数。  
   |
   | Default: true
  <interactiveMode>true</interactiveMode>
  -->
  <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.
   | 确定maven在执行构建时是否应该尝试连接到网络。  
   | 这将对工件下载、工件部署以及其他方面产生影响。
   | Default: false
  <offline>false</offline>
  -->
  <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.
   | 这是一个附加组标识符的列表,当根据前缀解析插件时,将会搜索这些组标识符。  
   | 当调用像“mvn prefix:goal”这样的命令行时。 Maven将自动添加组标识符  
   | “org.apache.maven。 插件”和“org.codehaus。 Mojo,如果列表中没有这些内容。  
   |-->
  <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.
   | 这是身份验证配置文件的列表,由系统中使用的服务器id进行键控。  
   | 只要maven必须连接到远程服务器,就可以使用身份验证配置文件。 
   |-->
  <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).
     | 指定连接到特定服务器时使用的身份验证信息,标识为  
     | 系统中的唯一名称(由下面的“id”属性引用)| 
     | NOTE: You should either specify username/password OR privateKey/passphrase, since these pairings are
     |       used together.
     | 注意:您应该指定用户名/密码或privateKey/ passpphrase,因为这些对是一起使用。
     |
    <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>
    -->
    <server> 
      <id>releases</id> 
      <username>ycq</username> 
      <password>Ycq19950319</password> 
    </server> 
    <server> 
      <id>snapshots</id> 
      <username>ycq</username> 
      <password>Ycq19950319</password> 
    </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.
   | 它的工作方式是这样的:POM可以声明一个存储库来解析特定的工件。  
   | 然而,这个存储库有时可能会出现流量过大的问题,因此人们已经进行了镜像  
   | 它去了好几个地方。  
   |
   | 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.
   | 该存储库定义将有一个惟一的id,因此我们可以为它创建一个镜像引用  
   | 存储库,用作替代下载站点。 镜像站点将是首选  
   | 服务器用于该存储库。  
   |-->
  <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.
     | 指定要使用的存储库镜像站点,而不是给定的存储库。 的存储库  
     | 此镜像服务的ID与此镜像的mirrorOf元素相匹配。 IDs使用  
     | 用于继承和直接查找,并且在镜像集中必须是唯一的。  
     |
    <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>mirror</id>
      <mirrorOf>central</mirrorOf>
      <name>mirror</name>
      <url>https://maven.aliyun.com/nexus/content/groups/public</url>
    </mirror>
    <mirror>
      <id>alimaven</id>
      <mirrorOf>central</mirrorOf>
      <name>aliyun maven</name>
      <url>http://maven.aliyun.com/nexus/content/repositories/central</url>
    </mirror>
    <mirror>
      <id>alimaven</id>
      <name>aliyun maven</name>
      <url>http://maven.aliyun.com/nexus/content/groups/public</url>
      <mirrorOf>central</mirrorOf>
    </mirror>

    <mirror>
      <id>central</id>
      <name>Maven Repository Switchboard</name>
      <url>http://repo1.maven.org/maven2</url>
      <mirrorOf>central</mirrorOf>
    </mirror>

    <mirror>
      <id>repo2</id>
      <mirrorOf>central</mirrorOf>
      <name>Human Readable Name for this Mirror.</name>
      <url>http://repo2.maven.org/maven2</url>
    </mirror>
    <mirror>
      <id>google-maven-central</id>
      <name>Google Maven Central</name>
      <url>https://maven-central.storage.googleapis.com
      </url>
      <mirrorOf>central</mirrorOf>
    </mirror>
    <!-- 中央仓库在中国的镜像 -->
    <mirror>
      <id>maven.net.cn</id>
      <name>one of the central mirrors in china</name>
      <url>http://maven.net.cn/content/groups/public</url>
      <mirrorOf>central</mirrorOf>
    </mirror>

    <!-- 私服仓库 -->
    <mirror>
      <id>privite_maven</id>
      <name>one of the central mirrors in china</name>
      <url>http://120.25.***.***:8081/repository/ycq/</url>
      <mirrorOf>central</mirrorOf>
    </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>
  </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.
   | 这是一个配置文件列表,可以以多种方式激活,也可以修改  
   | 构建过程。 xml中提供的配置文件旨在提供本地计算机-  
   | 允许构建在本地环境中工作的特定路径和存储库位置。  
   |
   | 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.
   | 例如,如果你有一个集成测试插件-像cactus -需要知道在哪里  
   | 您的Tomcat实例已经安装,您可以在这里提供一个变量,使该变量是  
   | 在配置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. 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.
   | 如上所述,可以通过多种方式激活概要文件。 一种方法- activeProfiles  
   | 本文档(settings.xml)部分—将在后面讨论。 另一种方法是  
   | 依赖于系统属性的检测,要么匹配属性的特定值,  
   | 或者仅仅是测试它的存在。 配置文件也可以通过JDK版本前缀激活,其中a  
   |'1.4'可能会在JDK版本'1.4.2_07'上执行构建时激活配置文件。  
   | 最后,可以直接从命令行指定活动概要文件的列表。
   |
   | 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中插件的变量。  
   |
   |-->
  <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.
     | 指定构建过程的一组介绍,将使用一个或多个  
     | 上面描述的机制。 为了继承的目的,并通过<activatedProfiles/>激活配置文件  
     | 或命令行,配置文件必须有一个唯一的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.
     | 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.
     | 一个受鼓励的配置文件识别的最佳实践是使用一致的命名约定  
     | 对于配置文件,例如'env-dev', 'env-test', 'env-production', 'user-jdcasey', 'user-brett'等。  
     | 这将使理解所引入的概要文件集试图做什么变得更加直观  
     | 要完成,特别是当您只有一个用于调试的配置文件id列表时。 
     |
     | This profile example uses the JDK version to trigger activation, and provides a JDK-specific repo.
     | 这个配置文件示例使用JDK版本来触发激活,并提供了一个特定于JDK的回购。 
     |
    <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>
    -->
    <profile>
      <id>jdk-1.8</id>
      <activation>
        <activeByDefault>true</activeByDefault>
        <jdk>1.8</jdk>
      </activation>
      <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
      </properties>
    </profile>
    <profile>    
      <!--profile 的 id--> 
      <id>dev</id>    
      <repositories>    
        <repository>   
          <!--仓库 id,repositories 可以配置多个仓库,保证 id 不重复--> 
          <id>nexus</id>    
          <!--仓库地址,即 nexus 仓库组的地址--> 
          <url>http://120.25.176.216:8081/repository/ycq/</url>    
         <!--是否下载 releases 构件--> 
          <releases>    
            <enabled>true</enabled>    
          </releases>    
          <!--是否下载 snapshots 构件--> 
          <snapshots>    
            <enabled>true</enabled>    
          </snapshots>    
        </repository>    
      </repositories>   
      <pluginRepositories>   
          <!-- 插件仓库,maven 的运行依赖插件,也需要从私服下载插件 --> 
          <pluginRepository>   
              <!-- 插件仓库的 id 不允许重复,如果重复后边配置会覆盖前边 --> 
              <id>public</id>   
              <name>Public Repositories</name>   
              <url>http://120.25.176.216:8081/repository/ycq/</url>   
          </pluginRepository>   
      </pluginRepositories>   
    </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:
     | 下面是另一个配置文件,由系统属性'target-env'激活,值为'dev',  
     | 它提供了到Tomcat实例的特定路径。 要使用这个,你的插件配置  
     | 可能看起来像:  
     |
     | ...
     | <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.
     | 注意:如果你只想在某人设置'target-env'为时注入此配置  
     | 任何内容,您都可以在激活属性中去掉<value/>|
    <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>
  -->
  <activeProfiles> 
    <activeProfile>dev</activeProfile> 
  </activeProfiles> 
</settings>

  • 1
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值