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

常用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的ssm项目配置文件

    在本主题中,我们将深入探讨Maven如何管理和组织SSM项目的配置文件,以及这些配置文件的主要功能。 1. Maven项目结构与配置: Maven是一个强大的构建工具,它通过一个统一的项目对象模型(Project Object Model, ...

    maven配置文件(不包含仓库).zip

    Maven是Java开发中不可或缺的构建工具,它简化了项目的...如果你是初次接触Maven,建议先了解基本概念和常用命令,再结合这个配置文件进行实践。同时,不断学习和掌握Maven的最佳实践,将使你的Java开发工作更加高效。

    2017年12月所有最新版本,SSM jar包 和maven文件,以及3个配置文件

    5. **配置文件**:SSM框架的运行离不开配置文件。Spring的配置文件(如`applicationContext.xml`)用于定义bean及其依赖关系;Spring MVC的配置文件(如`servlet-context.xml`)则用于设置Web应用的路由规则和视图...

    maven+ssm基础配置文件

    在这个名为“maven+ssm基础配置文件”的压缩包中,包含了构建一个SSM项目所需的关键配置文件。接下来,我们将深入探讨这些文件的作用和配置细节。 1. `rom.xml`:这个名字可能是误写,通常在SSM项目中,我们可能会...

    Maven总结【含配置文件】

    Maven 使用XML格式的配置文件(pom.xml)来描述项目信息、构建指令和依赖关系。 ** pom.xml 配置文件** pom.xml 文件是 Maven 的核心,它包含了项目的元数据,如项目名称、版本、描述、开发者信息等。更重要的是,...

    maven配置命令及项目部署

    maven配置文件setting.xml setting.xml文件是maven的配置文件,用于配置maven的仓库、代理、镜像等信息。setting.xml文件通常位于maven的安装目录中。 maven是一个功能强大且灵活的项目管理和综合工具,提供了...

    maven配置教程,图文,阿里云镜像

    2. **设置用户配置文件**:Maven的主要配置文件是`settings.xml`,它位于`%USER_HOME%\.m2\`目录下(Windows系统)或`~/.m2/`(Unix/Linux系统)。这个文件包含Maven的全局配置,如本地仓库位置、代理服务器等。 ##...

    springboot+maven打包demo【将依赖与配置文件打包到jar包外部】

    在本文中,我们将深入探讨如何使用Spring Boot和Maven来构建一个项目,使得依赖和配置文件被打包到jar包外部,以实现更加灵活的项目管理。这个方法对于那些需要根据不同环境进行定制配置或者频繁更新配置的应用来说...

    maven web pom文件常用配置

    总的来说,`pom.xml`文件是Maven项目的核心配置文件,它定义了项目的基本信息、依赖关系、构建过程和发布策略。理解并熟练掌握`pom.xml`的配置,能有效提高开发效率,确保项目构建的一致性和可重复性。通过不断学习...

    Springboot多模块maven配置实例

    本文将详细探讨如何在Spring Boot项目中实现多模块的Maven配置。 首先,我们要理解什么是多模块项目。在大型项目中,通常会将不同的功能模块拆分成单独的子项目,每个子项目负责一部分业务逻辑,这样有利于代码的...

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

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

    李兴华maven配置与使用

    **李兴华maven配置与使用** Maven是一款强大的项目管理工具,主要应用于Java开发领域。它通过统一的构建过程,简化了项目的构建、依赖管理和文档生成,使得开发者能够更专注于代码本身。以下是对Maven配置与使用的...

    maven生成可执行exe文件

    1. **Maven配置** Maven项目通常由`pom.xml`文件进行配置。在该文件中,我们需要添加用于创建可执行文件的插件。一个常用的插件是`exec-maven-plugin`,它允许我们指定主类并生成可执行文件。 2. **添加插件依赖**...

    maven安装文件

    Maven的配置文件`settings.xml`位于`%M2_HOME%\conf`目录下。这个文件主要用于配置本地仓库路径、远程仓库地址、代理设置等。你可以根据需要对这些设置进行个性化修改。 ### 六、首次使用Maven Maven使用`pom.xml`...

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

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

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

    在使用Maven时,配置文件`settings.xml`扮演着核心角色,它定义了Maven的行为方式和个性化设置。 `Maven的阿里云镜像配置文件Setting.xml`主要关注的是Maven如何高效地下载依赖。在默认情况下,Maven会从中央仓库...

    Maven配置SVN的方法和SVN包全套

    一、Maven配置SVN基础 1. 添加 SVN 插件:在 Maven 的 `pom.xml` 文件中,我们需要添加 SVN 相关的插件,如 `maven-scm-plugin`。这允许Maven与SVN进行交互,例如,执行`checkout`、`commit`、`update`等操作。下面...

Global site tag (gtag.js) - Google Analytics