maven的settings.xml文件详解

settings.xml主要元素:


  
  
  
  
  
  
  
  
  
  

 1  LocalRepository

作用:设置本地仓库的路径

默认值: ${user.home}/.m2/repository

Eg:

C:\work\repository

 

2  InteractiveMode

作用:表示maven是否需要和用户交互以获得输入(暂时不清楚)

默认值:true

 

3 UsePluginRegistry

作用:maven是否需要使用plugin-registry.xml文件来管理插件版本

默认:false

 

4 Offline

作用:表示maven是否需要在离线模式下运行

默认:false

注:在网络不好或安全因素时,可以设置为True

 

5 PluginGroups

作用:当插件的groupid没有显示提供时,提供默认的groupId列表

默认有:org.apache.maven.plugins  和  org.codehaus.mojo

 

proxies

作用:Maven在进行联网时需要使用到的代理

Eg:


  
      xxx
      true
      http
      用户名
      密码
      代理服务器地址
      代理服务器的端口
      不使用代理的主机
  

 

servers

作用:配置deploy时远程服务器的用户名和密码(上传项目时,在POM中的distributionManagement的URL的验证信息,有些远程服务器也需要用户密码才能下载依赖)

Eg:

 
    
      nexus
      admin
      admin123
    
  

 

Mirrors

作用:镜像仓库(加速jar下载,替代访问 默认的maven的远程仓库(https://repo1.maven.org/maven2/)或者设置的远程仓库,常用于配置 阿里云镜像或 私服镜像)

Eg:


    
      alimaven
      aliyun maven
      http://maven.aliyun.com/nexus/content/groups/public/
      central        
    
  

 

9 profiles

作用:配置多种环境参数的profile


    
      
      nexus
      
      
      
      
      
      
      
      
    
  

9.1 activation:自动触发该profile的条件逻辑

Eg:


  
  false
  
  1.5
  
  
    
    Windows XP
    
    Windows
    
    x86
    
    5.1.2600
  
  
  
    
    mavenVersion
    
    2.0.3
  
  
  
    
    ${basedir}/file2.properties
    
    ${basedir}/file1.properties
  

9.2 properties:存放变量,如果该profile激活,那么在pom.xml 可以用${xx}来使用

Eg:


        http://127.0.0.1:8082

pom文件里可以使用${nexus.ip}这个变量

9.3 Repositories:下载依赖的jar的远程仓库的列表

注意:一般包括releases(稳定版)和snapshots(快照版)

Eg:


        
          central
          ${nexus.ip}/repository/maven-public/
          
              true
              always
            warn
          
          true
        

9.4 pluginRepositories:发现下载插件的远程仓库列表

Eg:


        
          central
          ${nexus.ip}/repository/maven-public/
          
              true
              always
            warn
            
          true
        
      

 

10 ActiveProfiles

作用:手动激活profiles的列表,可以同时激活多个profile,如果有相同属性,后面的会覆盖前面的

Eg:


    nexus

 

 

注:

1  一般配置阿里云镜像仓库就可以了,配置镜像仓库可以在settings.xml 里的mirrors 或  profile的repositories里 或 pom文件的profile的repository里配置。镜像仓库是不需要验证信息的

2 nexus的配置:https://blog.csdn.net/qq_35720307/article/details/86994191

 

 

 

 

 

 

你可能感兴趣的:(maven)