精华内容
下载资源
问答
  • Maven settings.xml配置

    千次阅读 2019-04-02 09:06:06
    Maven settings.xml配置本地仓库 localRepository配置本地仓库交互模式 interactiveMode离线模式 offline插件组 pluginGroups代理设置 proxies服务器 servers镜像仓库 mirrors配置阿里镜像个性配置 profiles修改jdk...

    本地仓库 localRepository

    本地仓库配置,默认在${user.home}/.m2/repository

    <localRepository>${user.home}/.m2/repository</localRepository>
    

    配置本地仓库

    <localRepository>D:\maven-repository\repository</localRepository>
    

    交互模式 interactiveMode

    交互模式,默认: true
    如果设为false,那么当Maven需要用户进行输入的时候,它会使用一个默认值。

    <interactiveMode>true</interactiveMode>
    

    离线模式 offline

    离线模式,默认: false。
    这个属性表示在Maven进行项目编译和部署等操作时是否允许Maven进行联网来下载所需要的信息。
    true表示不查找。

    <offline>false</offline>
    

    插件组 pluginGroups

    插件组,内部由n个pluginGroup节点组成,默认自带了org.apache.maven.plugins和org.codehaus.mojo。
    pluginGroup元素指定的是plugin的groupId,表示当通过plugin的前缀来解析plugin的时候到哪里寻找。
    若有特殊的需求是可进行扩展。

    <pluginGroups>
    	<pluginGroup>com.your.plugins</pluginGroup>
    </pluginGroups>
    

    代理设置 proxies

    代理设置,内部由n个proxy节点组成,表示Maven在进行联网时需要使用到的代理。
    部分公司出于安全考虑会需要员工通过代理才可上网,这时,就需配置该节点的参数了。

    参数说明:
    id:唯一标识符
    active:是否被激活使用,默认为true。当有多个proxy节点存在时,用于选择使用哪个代理,但同一时间仅有一个代理会被被激活
    protocol:协议类型
    username:用户名,没有可不填
    password:密码,没有可不填
    host:IP地址
    port:端口号
    nonProxyHosts:不使用代理的地址
    以上参数在通常配置代理的情况都会使用到,一样填上即可,最终的代理地址为protocol://host:port
    <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>
    

    服务器 servers

    服务器,内部由n个server节点组成。
    需要连接到一个远程服务器的时候需要使用到的验证方式。
    pom.xml中的distributionManagement元素定义了开发库,特定的username和password需要在此配置
    有2种配置方式:

    1. 通过id匹配,username和password进行认证登录;
    2. 通过id匹配指向一个privateKey(私钥)和一个passphrase
    <servers>
    	<server>
    		<id>deploymentRepo</id>
    		<username>repouser</username>
    		<password>repopwd</password>
    	</server>
    	<server>
    		<id>siteServer</id>
    		<privateKey>/path/to/private/key</privateKey>
    		<passphrase>optional; leave empty if not used.</passphrase>
    	</server>
    </servers>
    

    镜像仓库 mirrors

    镜像仓库,内部由n个mirror节点组成。
    用来代替中央仓库(Maven默认的远程仓库),用于提升传输速度。

    参数说明:
    id:唯一标识符
    name:定义一个容易看懂的名称。
    url:表示该镜像的url。当Maven在建立系统的时候就会使用这个url来连接到我们的远程仓库。
    mirrorOf:用来表示该mirror是关联的哪一个仓库,其值为其关联仓库的id。
    当要同时关联多个仓库时,这多个仓库之间可以用逗号隔开;
    当要关联所有的仓库时,可以使用“*”表示;
    当要关联除某一个仓库以外的其他所有仓库时,可以表示为“ ,!repositoryId”;
    当要关联不是localhost或用file请求的仓库时,可以表示为“external:
    ”。
    <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>
    </mirrors>
    

    配置阿里镜像

    <mirrors>
    	<mirror>
    		<id>alimaven</id>
    		<name>aliyun maven</name>
    		<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
    		<mirrorOf>central</mirrorOf>
    	</mirror>
    </mirrors>
    

    个性配置 profiles

    个性配置,内部由n个profile节点组成。profile元素由activation、repositories、pluginRepositories和properties四个元素组成。
    当一个profile在settings.xml中是处于活动状态并且在pom.xml中定义了一个相同id的profile时,settings.xml中的profile会覆盖pom.xml中的profile。

    <profiles>
    	<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>env-dev</id>
    		<activation>
    			<property>
    				<name>target-env</name>
    				<value>dev</value>
    			</property>
    		</activation>
    		<properties>
    			<tomcatPath>/path/to/tomcat/instance</tomcatPath>
    		</properties>
    	</profile>
    </profiles>
    

    参数说明:

    • id:唯一标识符
    • activation:激活条件,例:
    <activation>
    	<activeByDefault>false</activeByDefault>
    	<jdk>[1.6,1.8)</jdk>
    	<os>
    		<name>Windows 7</name>
    		<family>Windows</family>
    		<arch>x86</arch>
    		<version>5.1.2600</version>
    	</os>
    	<file>
    		<exists>${basedir}/file2.properties</exists>
    		<missing>${basedir}/file1.properties</missing>
    	</file>
    	<property>
    		<name>mavenVersion</name>
    		<value>2.0.3</value>
    	</property>
    </activation>
    
      • activeByDefault: 当其值为true的时候表示如果没有其他的profile处于激活状态的时候,该profile将自动被激活。
      • jdk: 当jdk的版本满足条件的时候激活,
      • os:表示当操作系统满足条件的时候激活,例:
      • file:表示当文件存在或不存在的时候激活,exists表示存在,missing表示不存在。
      • property:是键值对的形式,表示当Maven检测到了这样一个键值对的时候就激活该profile。
    • repositories:用于定义远程仓库的,当该profile是激活状态的时候,这里面定义的远程仓库将作为当前pom的远程仓库,例:
    <repositories>
    	<repository>
    		<id>codehausSnapshots</id>
    		<name>Codehaus Snapshots</name>
    		<url>http://snapshots.maven.codehaus.org/maven2</url>
    		<layout>default</layout>
    		<releases>
    			<enabled>false</enabled>
    			<updatePolicy>always</updatePolicy>
    			<checksumPolicy>warn</checksumPolicy>
    		</releases>
    		<snapshots>
    			<enabled>true</enabled>
    			<updatePolicy>never</updatePolicy>
    			<checksumPolicy>fail</checksumPolicy>
    		</snapshots>
    	</repository>
    </repositories>
    
      • releases、snapshots:这是对于工件的类型的限制。
        • enabled:表示这个仓库是否允许这种类型的工件
        • updatePolicy:表示多久尝试更新一次。可选值有always、daily、interval:minutes(表示每多久更新一次)和never。
        • checksumPolicy:当Maven在部署项目到仓库的时候会连同校验文件一起提交,checksumPolicy表示当这个校验文件缺失或不正确的时候该如何处理,可选项有ignore、fail和warn。
    • pluginRepositories:在Maven中有两种类型的仓库,一种是存储工件的仓库,另一种就是存储plugin插件的仓库。pluginRepositories的定义和repositories的定义类似,它表示Maven在哪些地方可以找到所需要的插件。

    • properties:用于定义属性键值对的。当该profile是激活状态的时候,properties下面指定的属性都可以在pom.xml中使用。

    修改jdk版本

    <profiles>
    	<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>
    </profiles>
    

    激活的profile activeProfiles

    激活的profile
    activeProfile值为profile中所定义的id,在这里定义的activeProfile总是被激活

    <activeProfiles>
    	<activeProfile>alwaysActiveProfile</activeProfile>
    	<activeProfile>anotherAlwaysActiveProfile</activeProfile>
    </activeProfiles>
    
    展开全文
  • Maven settings.xml配置文件,配置了远程仓库地址,只需修改自己的本地仓库地址,便可使用,能够快速下载依赖jar包。本人亲测可用
  • maven settings.xml配置文件,亲试无问题,可以使用,eclipse和Myeclipse都可以
  • 主要介绍了详解Maven settings.xml配置(指定本地仓库、阿里云镜像设置),小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
  • MavenMaven settings.xml 配置镜像

    千次阅读 2020-09-08 16:43:42
    Maven settings.xml 配置镜像 settings.xml介绍 从settings.xml的文件名就可以看出,它是用来设置maven参数的配置文件。 并且,settings.xmlmaven的全局配置文件。而pom.xml文件是所在项目的局部配置。 ...

                           【Maven】 Maven settings.xml 配置镜像

    settings.xml介绍

        从settings.xml的文件名就可以看出,它是用来设置maven参数的配置文件。

        并且,settings.xml是maven的全局配置文件。而pom.xml文件是所在项目的局部配置。

        settings.xml中包含类似本地仓储位置、修改远程仓储服务器、认证信息等配置。

        settings.xml文件一般存在于两个位置:
        (1)全局配置: ${M2_HOME}/conf/settings.xml;


        (2)用户配置: user.home/.m2/settings.xml。

        配置优先级:
        (1)需要注意的是:局部配置优先于全局配置。
        (2)配置优先级从高到低:pom.xml> user settings > global settings
        (3)如果这些文件同时存在,在应用配置时,会合并它们的内容,如果有重复的配置,优先级高的配置会覆盖优先级低的。

    Mirrors

    作用:为仓库列表配置的下载镜像列表。

    <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
       | The path to the local repository maven will use to store artifacts.
       |
       | Default: ${user.home}/.m2/repository
    
      -->
    
    ......
    <mirrors>
        <!-- 给定仓库的下载镜像。 -->
        <mirror>
          <!-- 该镜像的唯一标识符。id用来区分不同的mirror元素。 -->
          <id>alimaven</id>
          <!-- 镜像名称 -->
          <name>aliyun maven</name>
          <!-- 该镜像的URL。构建系统会优先考虑使用该URL,而非使用默认的服务器URL。 -->
          <url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
          <!-- 被镜像的服务器的id。例如,如果我们要设置了一个Maven中央仓库 
         (http://repo.maven.apache.org/maven2/)的镜像,就需要将该元素设置成central。这必须和中 
          央仓库的id central完全一致。 -->
          <mirrorOf>central</mirrorOf>
        </mirror>
    
      </mirrors>
    

    Mirror镜像

        mirror相当于一个拦截器,它会拦截maven对remote repository的相关请求,把请求里的remote repository地址,重定向到mirror里配置的地址。

    1 没有配置mirror

    2 配置mirror

    <mirrorOf></mirrorOf>

    <mirrorOf></mirrorOf>标签里面放置的是要被镜像的Repository ID。为了满足一些复杂的需求,Maven还支持更高级的镜像配置:

    <mirrorOf>central</mirrorOf> 
    表示该配置为中央仓库的镜像,任何对于中央仓库的请求都会转至该镜像
    
    <mirrorOf>*</mirrorOf> 
    匹配所有仓库请求,即将所有的仓库请求都转到该镜像上
    
    <mirrorOf>repo1,repo2</mirrorOf> 
    将仓库repo1和repo2的请求转到该镜像上,使用逗号分隔多个远程仓库。 
    
    <mirrorOf>*,!repo1</miiroOf> 
    匹配所有仓库请求,repo1除外,使用感叹号将仓库从匹配中排除。
    

    举例:

      <mirror>    
          <id>奇葩-mirror</id>  
          <name>奇葩-mirror</name>
          <url>https://奇葩/repo/</url>  
          <mirrorOf>central</mirrorOf>    
        </mirror> 
     
        <mirror>    
          <id>nexus-aliyun</id>  
          <name>nexus-aliyun</name>
          <url>http://maven.aliyun.com/nexus/content/groups/public</url>  
          <mirrorOf>*</mirrorOf>    
        </mirror>

     以上配置,当maven发现所需的奇葩jar在阿里镜像中没有时,会自动去奇葩镜像中寻找。奇葩jar的确下载下来了。

    几个好用Maven 镜像仓库地址

    1 阿里云镜像

    <mirror>
        <id>nexus-aliyun</id>
        <name>Nexus aliyun</name>
        <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
        <mirrorOf>central</mirrorOf>
    </mirror>

    2 maven官方2号镜像

    <mirror>
        <id>repo2</id>
        <name>Mirror from Maven Repo2</name>
        <url>http://repo2.maven.org/maven2/</url>
        <mirrorOf>central</mirrorOf>
    </mirror>

    3 maven的UK镜像

    <mirror>
        <id>ui</id>
        <name>Mirror from UK</name>
        <url>http://uk.maven.org/maven2/</url>
        <mirrorOf>central</mirrorOf>
    </mirror>

    4 JBoss 镜像

    <mirror>
        <id>jboss-public-repository-group</id>
        <mirrorOf>central</mirrorOf>
        <name>JBoss Public Repository Group</name>
        <url>http://repository.jboss.org/nexus/content/groups/public</url>
    </mirror>

     

    展开全文
  • 开源中国Mavensettings.xml配置详解,用户只需配置自己本机的localRepository即可使用。
  • 转载:Maven settings.xml配置(指定本地仓库、阿里云镜像设置) 一、settings.xml文件会在两个目录下存在:1、Maven安装目录(全局):%MAVEN_HOME%\conf\settings.xml2、用户安装目录(用户):${user.home}\.m2...

    转载:Maven settings.xml配置(指定本地仓库、阿里云镜像设置)

    一、settings.xml文件会在两个目录下存在:

    1、Maven安装目录(全局):%MAVEN_HOME%\conf\settings.xml

    2、用户安装目录(用户):${user.home}\.m2\settings.xml

    第一个是全局配置,第二个是用户配置。当两者都存在,它们的内容将被合并,特定于用户的settings.xml文件占主导地位。

    如果从头开始创建用户特定的配置,可以将全局的settings.xml复制到${user.home}\.m2目录下。

    我的Maven安装目录:(%MAVEN_HOME%)D:\apache-maven-3.5.2

    我的用户安装目录:(${user.home})C:\Users\Administrator

    打开用户目录下的settings.xml,如图所示:


    二、指定本地仓库

    1、本机新建一个文件夹当做本地仓库

    我建的文件夹路径为:F:\MavenRepository

    2、在settings.xml中添加localRepository标签


    三、配置阿里云镜像(因为要访问国外服务器,会很慢)

    在settings.xml文件中的mirrors下添加mirror标签

    <mirror>

     <id>alimaven</id>

     <name>aliyun maven</name>

     <url>http://maven.aliyun.com/nexus/content/groups/public/</url>

     <mirrorOf>central</mirrorOf>

    </mirror>


    三、用Maven命令创建一个Java项目,可以看到初次创建会加载一些jar包

    mvn archetype:generate -DarchetypeArtifactId=maven-archetype-quickstart -DgroupId=com.abc -DartifactId=Blog


    看到如上图所示内容,表示用Maven创建Java工程成功!

    项目结构图如图所示,缺少哪个文件夹就自己创建




    展开全文
  • 在使用maven的时候默认缓存本地仓储到C盘,为了转移目录,我们设置settings.xml,当国外网络不理想的时候,为了快速访问国内仓储,我们设置settings.xml。此资源中包含了官方默认的,也有配置好的,及使用文档,具体...
  • Maven Settings.xml配置文件备份

    万次阅读 2018-04-13 17:36:13
    Settings.xml配置文件:&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license ...

    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.home}/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.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
       | 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:\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>alimaven-central</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>jboss-public-repository-group</id>
                 <mirrorOf>central</mirrorOf>
                 <name>JBoss Public Repository Group</name>
                <url>http://repository.jboss.org/nexus/content/groups/public</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>ibiblio</id>
                <mirrorOf>central</mirrorOf>
                 <name>Human Readable Name for this Mirror.</name>
                <url>http://mirrors.ibiblio.org/pub/mirrors/maven2/</url>
             </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>-->
    
      </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>
        -->
    
    	<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> 
    
        <!--
         | 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>


    主要方便下次寻找。


    也可以在这里进行下载:https://download.csdn.net/download/zhongqi2513/10400447


    展开全文
  • Maven settings.xml配置详解

    千次阅读 2017-05-13 17:01:51
    setting.xml配置文件maven配置文件settings.xml存在于两个地方:1.安装的地方:${M2_HOME}/conf/settings.xml 2.用户的目录:${user.home}/.m2/settings.xml前者又被叫做全局配置,对操作系统的所有使用者生效;...
  • 这是maven 自定义仓库配置方案。本地仓库默认放在C盘,如果要想将本地仓库转移到指定到自动以的位置,就需要配置setting.xml,下载后只需修改本地仓库的配置即可!
  • maven settings.xml配置多个镜像地址

    万次阅读 2018-05-30 22:07:42
    maven conf/settings.xml配置多个镜像地址防止部分项目无法拉取: &amp;lt;mirrors&amp;gt; &amp;lt;!-- mirror | Specifies a repository mirror site to use instead of a given repository. The ...
  • | #用户级别,面向单个用户配置,即每个用户都可以自定义settings.xml供己方使用  | This is the configuration file for Maven. It can be specified at two levels:  | 1. User Level. This settings.xml file ...
  • 1、Maven安装目录(全局):%MAVEN_HOME%\conf\settings.xml 2、用户安装目录(用户):${user.home}\.m2\settings.xml 第一个是全局配置,第二个是用户配置。当两者都存在,它们的内容将被合并,特定于用户的...

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 75,106
精华内容 30,042
关键字:

mavensettings.xml配置