`
bugyun
  • 浏览: 545208 次
社区版块
存档分类
最新评论

常用maven配置文件配置

 
阅读更多

以下配置都是基于 conf/settings.xml文件

 

1. 配置maven下载包的路径;

  1. <localRepository>D:\Develop\apache-maven-3.2.3\repository</localRepository>  

 

 

2. 配置下载源,这里配置的事阿里巴巴的maven仓库;

  1.     <mirror>  
  2.       <id>alimaven</id>  
  3.       <name>aliyun maven</name>  
  4.       <url>http://maven.aliyun.com/nexus/content/groups/public/</url>  
  5.       <mirrorOf>central</mirrorOf>          
  6.     </mirror> 

 

 3. 配置Jdk编译环境版本 

  1.     <profile>    
  2.         <id>jdk-1.8</id>    
  3.         <activation>    
  4.           <activeByDefault>true</activeByDefault>    
  5.           <jdk>1.8</jdk>    
  6.       </activation>    
  7.             <properties>    
  8.                 <maven.compiler.source>1.8</maven.compiler.source>    
  9.                 <maven.compiler.target>1.8</maven.compiler.target>    
  10.                 <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>    
  11.             </properties>    
  12.         </profile> 

 

 

<?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:\Develop\apache-maven-3.2.3\repository</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</id>
      <name>aliyun maven</name>
      <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
      <mirrorOf>central</mirrorOf>        
    </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>
    -->
   
    <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>

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

 

分享到:
评论

相关推荐

    工作中常用maven配置文件,拿来即用

    工作中常用maven配置文件,拿来即用

    Maven配置阿里云镜像settings.xml文件

    在安装Maven构建工具后,Maven仓库镜像站点默认是国外的,因为网络原因,在构建...所以我们一定要把仓库镜像站点改为国内的才能顺利下载,通常比较常用得是阿里云镜像,已经配置好的settings.xml文件可以直接替换使用。

    Maven 配置文件 生命周期 常用命令详解

    Maven是围绕着构建生命周期的核心概念为原型,整个项目的创建和部署都是围绕着生命周期展开的,一个生命周期由若干个生命周期阶段组成。下面通过本文给大家介绍Maven 配置文件 生命周期 常用命令详解,一起看看吧

    Maven 配置文件替换插件,实现不同环境打包不同配置 丢弃profile冗长配置的 不二之选.zip

    将下载的压缩包解压到开发工具常用的目录,例如D:\developer\apache-maven-3.9.1-bin。 配置系统环境变量。在Windows系统中,进入“高级系统设置”,点击“环境变量”。在“系统变量”中编辑Path,添加Maven的bin...

    Maven常用命令大全与pom文件讲解

    摘要:本文主要讲解是Maven使用过程中一些常用的命令,并配上图片说明,最后还讲了pom.xml文件的一些构造。-D传入属性参数-P使用pom中指定的配置-e显示maven运行出错的信息-o离线执行命令,即不去远程仓库更新包-X...

    分享一个快的飞起的maven的settings.xml文件

    分享一个快的飞起的maven的settings.xml文件. 直接使用开源中国的中央仓库。

    Maven_pom.xml常用配置解析

    pom.xml 文件是 Maven 项目的核心配置文件,用于描述项目的结构、依赖关系和编译过程。 1. `&lt;project&gt;` 元素:pom.xml 文件的根元素,包含项目的基本信息,包括项目的名称、描述、版本、许可证等。 * `groupId`:...

    maven web pom文件常用配置

    NULL 博文链接:https://kanpiaoxue.iteye.com/blog/2005675

    史上最全的maven的pom.xml文件详解

    记录一下自己常用的maven工程的pom.xml配置详解,各个标签详解

    Maven安装和配置.doc

    配置 settings.xml 文件:Maven 的主要配置文件是 settings.xml,通常位于 Maven 的 conf 目录下。可以在该文件中设置 Maven 的全局配置,如镜像源、代理、仓库等。 配置 pom.xml 文件:在项目根目录下的 pom.xml ...

    maven项目中pom.xml配置文件

    maven项目中pom.xml配置文件,包含常用的mybatis,log4j,jdk,mysql连接等依赖

    eclipse maven setting.xml

    eclipse 集成maven 的配置文件 settings.xml ,配置了常用中央库镜像地址。只需配置本地仓库地址即可用。并对配置文件节点有中文说明

    maven常用的命令

    Maven 常用命令 Maven 是一个基于项目对象模型(Project Object Model,POM)...* `src/main/resource`:存放项目的资源文件,如配置文件等 了解这些命令和目录结构可以帮助您更好地使用 Maven 进行项目管理和构建。

    apache-maven-3.9.5-bin windows 64bit x86下载

    1、构建管理:Maven使用一个中央的配置文件(pom.xml)来定义项目的结构、依赖关系和构建脚本。通过定义项目的依赖关系,Maven能够自动下载、管理和构建这些依赖。 2、依赖管理:Maven能够自动解决项目的依赖关系,...

    java框架配置文件收集

    包括spring、mybatis、hibernate、maven的常用配置文件

    SSM框架的maven pom文件

    最全的SSM开发用到的pom文件,内含常用的包dependency配置,使用时只需复制到你的pom文件内,就可直接下载,最好是把maven的下载路径改为阿里云下载

    [maven] 常用插件解析.docx

    Maven 插件解析 ...maven-assembly-plugin 要求用户使用一个名为 assembly.xml 的文件来配置打包过程。 了解 Maven 插件的基本概念和常用插件能够帮助我们更好地使用 Maven,并避免重新发明轮子。

    适用于windows-x64位的maven压缩包

    conf目录为配置目录,你可以在里面进行maven的配置 lib包存储着maven的依赖,因为maven自己也是java构建的 复制当前的目录(注:最好不要有中文) 右键此电脑--&gt;属性--&gt;高级系统设置--&gt;环境变量 添加一个新的环境...

    Maven笔记.doc

    Maven 配置文件: 1. $user.home/.m2/settings.xml:当前用户范围的配置文件(如果没有,可以拷贝全局的过来); 2. $M2_HOME/conf/setting.xml:全局范围的配置文件,修改后影响本机所有用户配置; 3. setting.xml...

    SpringMVC基本框架(maven)

    2.标准配置文件格式:数据库配置、资源配置、log4j配置、spring配置; 3.jar包通过maven管理; 4.增加常用过滤器配置,可根据项目要求改写; 5.增加获取资源方法实例,可以获取配置文件中的常量。

Global site tag (gtag.js) - Google Analytics