Maven settings.xml文件节点配置详解

settings.xml基本结构


    
    
    
    
    
    
    
    
    
    

localRepository: 表示本地库的保存位置,也就是maven2主要的jar保存位置,默认在${user.dir}/.m2/repository,如果需要另外设置,就换成其他的路径。比如

D:\WorkFile\repository

offline: 如果不想每次编译,都去查找远程中心库,那就设置为true。当然前提是你已经下载了必须的依赖包。 默认false。

false

Servers :在POM中的 distributionManagement元素定义了开发库。然而,特定的username和pwd不能使用于pom.xml,所以通过此配置来保存server信息。

  • id:server 的id,用于匹配distributionManagement库id,比较重要。
  • username,password:用于登陆此服务器的用户名和密码
  • privateKey, passphrase:设置privatekey,以及passphrase
  • filePermissions,directoryPermissions:当库文件或者目录创建后,需要使用权限进行访问。
 
         
          server001 
          my_login 
          my_password 
          ${usr.home}/.ssh/id_dsa 
          some_passphrase 
          664 
          775 
           
        
         
          server002 
          my_login 
          my_password 
          ${usr.home}/.ssh/id_dsa 
          some_passphrase 
          664 
          775 
           
        
    

distributionManagement元素:
https://blog.csdn.net/qq_31924435/article/details/53745811
https://www.cnblogs.com/liu2-/p/9035181.html
Mirrors
表示镜像库,指定库的镜像,用于增加其他库

  • id,name:唯一的标志,用于区别镜像
  • url:镜像的url
  • mirrorOf:此镜像指向的服务id
      
	  nexus-aliyun    
	  nexus-aliyun  
	  http://maven.aliyun.com/nexus/content/groups/public    
	  central      
 
//阿里云镜像地址 

Proxies
此代理设置,主要用于无法直接访问中心的库用户配置。

  • id:代理的标志
  • active:是否激活代理
  • protocol, host, port:protocol://host:port 代理
  • username, password:用户名和密码
  • nonProxyHosts: 不需要代理的host
 
     
      myproxy 
      true 
      http 
      proxy.somewhere.com 
      8080 
      proxyuser 
      somepassword 
      *.google.com|ibiblio.org 
     
  

Profiles
类似于pom.xml中的profile元素

主要包括activation,repositories,pluginRepositories 和properties元素
刚开始接触的时候,会比较迷惑,这是maven中比较强大的功能——个性配置。
单独定义profile后,并不会生效,需要通过满足条件来激活。

repositories 和pluginRepositories 依照如下的配置,定义了本地开发库,用于release 发布。

 
     
        repo-local 
        Internal 开发库 
        http://192.168.0.2:8082/repo-local 
         
            true 
            never 
            warn 
         
         
            false 
         
        default 
     
 

 
     
        repo-local 
        Internal 开发库 
        http://192.168.0.2:8082/repo-local 
         
            true 
            never 
            warn 
         
         
            false 
         
        default 
     

releases, snapshots:每个产品的版本的Release或者snapshot(注:release和snapshot的区别,release一般是比较稳定的版本,而snapshot基本上不稳定,只是作为快照)

properties作为placeholder值,如ant的properties。

包括以下的5种类型值:

  1. env.X,返回当前的环境变量
  2. project.x:返回pom中定义的元素值,如project.version
  3. settings.x:返回settings.xml中定义的元素
  4. java系统属性:所有经过java.lang.System.getProperties()返回的值
  5. x:用户自己设定的值

Activation 用于激活此profile

  • jdk:如果匹配指定的jdk版本,将会激活
  • os:操作系统
  • property:如果maven能检测到相应的属性
  • file:用于判断文件是否存在或者不存在
 
        false 
        1.5 
         
          Windows XP 
          Windows 
          x86 
          5.1.2600 
         
         
          mavenVersion 
          2.0.3 
         
         
          ${basedir}/file2.properties 
          ${basedir}/file1.properties 
         
      

Active Profiles

除了使用activation来激活profile,同样可以通过activeProfiles来激活

env-test 表示指定的profile id

 
    env-test 
 

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

true

pluginGroups:在pluginGroups元素下面可以定义一系列的pluginGroup元素。表示当通过plugin的前缀来解析plugin的时候到哪里寻找。pluginGroup元素指定的是plugin的groupId。默认情况下,Maven会自动把org.apache.maven.plugins和org.codehaus.mojo添加到pluginGroups下。


    com.your.plugins
  

转自:https://www.cnblogs.com/avivaye/p/5336647.html

你可能感兴趣的:(Maven)