Maven配置私有仓库


前言

??当公司或个人具有自己独有的jar时,不想公开,一般就会放在自己的私有Maven仓库中,在项目中需要引用,此时就需要将公司私有仓库配置到maven当中,一般我们的maven配置的都是aliyun的maven公有仓库,但此时我们不但要配置私有仓库还要配置公有仓库,因为有的公有jar,私有仓库中不一定有,所以此时就涉及到maven多仓库配置喽。

maven配置一共分为两种

  1. 统一配置,通过maven的setting.xml文件配置,每个项目都可直接使用。
  2. 项目配置,在项目的pom.xml文件中配置(有得项目需要进行定制化配置,但其他项目又不需要这个仓库)

以下使用的统一配置方式来进行配置哈。项目配置可自行百度。希望可以帮助到大家。

1、Setting.xml

在本地maven的setting.xml配置文件中进行私有仓库配置。

标签中配置仓库访问账号和密码。

标签中配置仓库地址。

标签中配置多仓库使用。

中激活仓库,否则配置无效。


    
        nexus-repository
        central
        Nexus repository
        http://192.168.0.1::8081/content/groups/public/
    
    
        alimaven
        aliyun maven
        http://maven.aliyun.com/nexus/content/groups/public/\
        central
    


    
        repository
        
            
                central
                http://central
                true
                true
            
        
        
            
                central
                http://central
                true
                true
            
        
    

    
        alimaven
        
            
                central
                http://central
                true
                true
            
            
                Dcm4Che
                Dcm4Che
                http://www.dcm4che.org/maven2/
                
                    true
                
                
                    false
                
            
        
        
            
                nexus
                http://maven.aliyun.com/nexus/content/groups/public/
                
                    true
                
                
                    true
                
            
        
    


    repository
    alimaven

2、刷新IDEA项目

查看maven仓库引用 

此刻配置就成功了,即可使用远程私有仓库拉去jar,如果找不到相关jar,会自动去aliyun中央仓库下载公有maven坐标。