maven倉庫中心mirrors配置多個下載中心(執行最快的鏡像)


在日常生活中,我們使用maven下載需要的jar包,但是很多的時候由於中央倉庫沒有,所以我們沒有辦法下載到需要的jar包,手動去下載上,然后放入到lib下,然后build path有的時候會感到很不舒服,不是很是不實用。所以此處可以在maven的設置中心添加多個下載倉庫,這樣豐富了中央倉庫的下載地址。

本人使用的本地的maven(版本為3.1.1)。具體配置如下:
1、配置idea指定本地倉庫的maven

file-->Other Settings-->default settings-->搜索maven

2、配置本地maven(本地maven倉庫存放的位置)

 
3、核心配置(配置多個中央下載倉庫中心)

 

    <mirrors>
        <!-- mirror
         | Specifies a repository mirror site to use instead of a given repository. The repository that
         | this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
         | for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
         |
        <mirror>
          <!-- 唯一標識一個mirror -->
          <id>mirrorId</id>
          <!-- 代表了一個鏡像的替代位置,例如central就表示代替官方的中央庫 -->
          <mirrorOf>repositoryId</mirrorOf>
          <!-- 貌似沒多大用,相當於描述 -->
          <name>Human Readable Name for this Mirror.</name>
          <!-- 是官方的庫地址 -->
          <url>http://my.repository.com/repo/path</url>
        </mirror>
         -->
         <!--默認的中央倉庫-->
         <mirror>
          <id>mirrorId</id>
          <mirrorOf>repositoryId</mirrorOf>
          <name>Human Readable Name for this Mirror.</name>
          <url>http://my.repository.com/repo/path</url>
        </mirror>
        <!--自定義添加-->
        <mirror>    
          <id>repo2</id>    
          <mirrorOf>central</mirrorOf>    
          <name>Human Readable Name for this Mirror.</name>    
          <url>http://repo2.maven.org/maven2/</url>    
        </mirror>  
        <!--阿里雲鏡像-->
        <mirror>  
          <id>alimaven</id>  
          <name>aliyun maven</name>  
          <url>http://maven.aliyun.com/nexus/content/groups/public/</url>  
          <mirrorOf>central</mirrorOf>          
        </mirror>
         <mirror>    
          <id>ui</id>    
          <mirrorOf>central</mirrorOf>    
          <name>Human Readable Name for this Mirror.</name>    
          <url>http://uk.maven.org/maven2/</url>    
        </mirror>    
     
        <mirror>    
          <id>ibiblio</id>    
          <mirrorOf>central</mirrorOf>    
          <name>Human Readable Name for this Mirror.</name>    
          <url>http://mirrors.ibiblio.org/pub/mirrors/maven2/</url>    
        </mirror>  
     
        <mirror>    
          <id>jboss-public-repository-group</id>    
          <mirrorOf>central</mirrorOf>    
          <name>JBoss Public Repository Group</name>    
          <url>http://repository.jboss.org/nexus/content/groups/public</url>    
        </mirror>
        <!--訪問慢的網址放入到后面-->
         <mirror>    
          <id>CN</id>  
          <name>OSChina Central</name>         
          <url>http://maven.oschina.net/content/groups/public/</url>  
          <mirrorOf>central</mirrorOf>    
        </mirror>
        <mirror>    
          <id>net-cn</id>    
          <mirrorOf>central</mirrorOf>    
          <name>Human Readable Name for this Mirror.</name>    
          <url>http://maven.net.cn/content/groups/public/</url>     
        </mirror>
        <mirror>    
          <id>JBossJBPM</id>  
          <mirrorOf>central</mirrorOf>
          <name>JBossJBPM Repository</name>   
          <url>https://repository.jboss.org/nexus/content/repositories/releases/</url>  
        </mirror>
      </mirrors>

重要說明:

此處指定多個mirrors鏡像,鏡像只會執行第一個位置mirror。

官網說明如下:http://maven.apache.org/guides/mini/guide-mirror-settings.html

設置多個鏡像只會識別第一個鏡像下載jar包。配置的多個mirror可以都放着不影響,選取一個鏡像下載比較快的放在第一個就行。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM