记录maven配置 mirrorOf 坑

今天从远端download下公司一个maven项目时,pom.xml文件中一直报错,missing某些包,此时maven中settings.xml的主要配置如下

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


项目中pom.xml配置了客户的私服,如下:


    
        bank_central
        core Release Repository
        http://......:9090/repository/bank_central/
    
    
        bank_privrepository_snapshots
        core Snapshots Repository
        http://......:9090/repository/bank_privrepository_snapshots/
    



    
        bank_privrepository_interfaces
        bank_privrepository_interfaces
        http://......:9090/repository/bank_privrepository_interfaces/
        
            false
        
    
    
        bank_privrepository_snapshots
        bank_privrepository_snapshots
        http://......:9090/repository/bank_privrepository_snapshots/
        
            true
        
    


    
        
        nexus
        local nexus server
        http://......:9090/repository/bank_central/
        
            false
        
    

经历了反复的clean-build、maven force update及各种可能想得到的操作,某些依赖包依然无法下载。

后来突发奇想,将settings.xml中


配置项删除,重新force update,某些包可以下载下来了,但依然缺包,后来查阅各种资料,将setting.xml中*改为central


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

perfect!!!!!!!!!!!!!!!知其然不知其所以然,待更新

官方说明:https://maven.apache.org/guides/mini/guide-mirror-settings.html

*的意思就是(根据mirrorOf和repository的id)匹配所有的库(repository),这样就是说如果你需要某个jar,他会从镜像地址去下载这个jar。不管你配置了多少个库,即使这些库的地址不一样,仍然会从镜像地址访问


你可能感兴趣的:(maven)