maven配置总结(pom.xml和settings.xml)

maven配置总结

  • 一、pom.xml配置
    • 1、自定义参数
    • 2、依赖包版本管理
    • 3、depoly发布路径配置
    • 4、设定远程仓库下载路径,按设定顺序依次下载
    • 5、环境变量配置(一般用于打包控制配置)
  • 二、setting.xml配置
    • 1、配置镜像(可以理解为代理)
    • 2、配置服务密码
    • 3、配置统一远程仓库

一、pom.xml配置

1、自定义参数

	
       1.7.5
	   1.2.3
	

2、依赖包版本管理


        
           
				org.slf4j
				slf4j-api
				${slf4j.version}
			
			
                ch.qos.logback
                logback-core
                ${logback.version}
            
        

3、depoly发布路径配置

    
		
			maven-releases
			http://xxx/maven-releases/
		
		
			maven-snapshots
			http://xxx/repository/maven-snapshots/
		
	

4、设定远程仓库下载路径,按设定顺序依次下载

    
        <-- 需要密码的到setting中找密码 -->
        
            nexus-repos
            releases
            http://xxx/nexus/content/groups/public
          
        
        
            oschina-repos
            Oschina Releases
            http://maven.oschina.net/content/groups/public
        
    
    <-- 插件下载路径 -->
   
	    
	      maven-net-cn
	      Maven China Mirror
	      http://maven.net.cn/content/groups/public/
	      
	        	true
	      
	      
	        	false
	          
	    
  

5、环境变量配置(一般用于打包控制配置)


		
			dev
				
					true   #指定默认环境变量为dev
				
			
				
					
						src/main/exchange-robot/env-dev   #指定资源文件路径
						false
					
				
			
			  
	            0.1   #打包时覆盖原来的版本属性
	        
		

二、setting.xml配置

1、配置镜像(可以理解为代理)

  
    
		alimaven

		aliyun maven

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

		central 
	    # maven中有个顶级pom指定了中央仓库为central,只需要将这个仓库镜像到阿里云即可;也可以配置 *,!maven-releases,!maven-snapshots
    
  

2、配置服务密码


	
		maven-releases
		admin
		xxx
	
	
		maven-snapshots
		admin
		xxx
	

3、配置统一远程仓库

避免源代码中配置仓库,由于setting中不支持repositories标签,远程仓库默认需要到pom中配置。这里通过统一profils设置


    
      dev
	    
	        
	            nexus-repos
	            releases
	            http://xxx/nexus/content/groups/public
	          
	        
	            oschina-repos
	            Oschina Releases
	            http://maven.oschina.net/content/groups/public
	        
	        
  
  
    dev
  

你可能感兴趣的:(java)