Maven私有仓库搭建配置

研发团队考虑使用 Jenkins 进行一键构建、部署服务,其中构建使用 Maven 进行,构建时需要从 Maven 仓库中下载所需依赖,因此项目的各个模块 jar 包需要上传到本地私有仓库中供 Maven 构建时下载。

  1. 下载 Maven 程序包并解压缩到仓库服务器,启动服务,地址为:
http://172.22.151.183:8081/
  1. 配置 Jenkins 服务所在机器的 Maven , 配置文件路径:
C:\Users\Administrator\.m2\settings.xml
  1. 配置文件完整内容:


    
    
    
	
    
	
	
      maven-thirdpart
      admin
      admin123
    
	
	
      maven-releases
      admin
      admin123
    
	
	
      maven-snapshots
      admin
      admin123
    
		
	
      maven-public
      admin
      admin123
    
	
	
    
    C:\Users\Administrator\.m2\repository
    
    
		
            maven-snapshots
            *
            http://172.22.151.183:8081/repository/maven-snapshots/
        
		
            alimaven
            central
            aliyun maven jcenter
            https://maven.aliyun.com/repository/jcenter
        
        
            alimaven
            central
            aliyun maven
            http://maven.aliyun.com/nexus/content/repositories/central/
        
        
            alimaven
            aliyun maven
            http://maven.aliyun.com/nexus/content/groups/public/
            central
        
        
            central
            Maven Repository Switchboard
            http://repo1.maven.org/maven2/
            central
        
        
            repo2
            central
            Human Readable Name for this Mirror.
            http://repo2.maven.org/maven2/
        
        
            ibiblio
            central
            Human Readable Name for this Mirror.
            http://mirrors.ibiblio.org/pub/mirrors/maven2/
        
        
            jboss-public-repository-group
            central
            JBoss Public Repository Group
            http://repository.jboss.org/nexus/content/groups/public
        
        
            google-maven-central
            Google Maven Central
            https://maven-central.storage.googleapis.com
            
            central
        
        
        
            maven.net.cn
            oneof the central mirrors in china
            http://maven.net.cn/content/groups/public/
            central
        
    
	

  1. 项目模块 pom 文件配置:
	
    
        
            maven-snapshots
            http://172.22.151.183:8081/repository/maven-snapshots/
            
                false
            
            
                true
                
            
        
    
    
    
    
        
            maven-public
            http://172.22.151.183:8081/repository/maven-public/
            
                true
            
            
                false
            
        
    
    
    
    
        
            maven-snapshots
            maven-snapshots
            http://172.22.151.183:8081/repository/maven-snapshots/
        
    

以上,就是最最最简略的配置,甚至没有配置 release 发布版本仓库,因为我们项目目前需求只是 snapshot 快照版本,能够把依赖模块编译打包上传、web 服务模块构建时能够下载所需的依赖模块 jar 包即可。

你可能感兴趣的:(maven)