1. 程式人生 > 程式設計 >maven倉庫中心mirrors配置多個下載中心(執行最快的映象)

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

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

本人使用的本地的maven(版本為3.1.1)。具體配置如下:

1、配置idea指定本地倉庫的maven

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

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

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

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

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>aliyunmaven</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可以都放著不影響,選取一個映象下載比較快的放在第一個就行。

到此這篇關於maven倉庫中心mirrors配置多個下載中心(執行最快的映象)的文章就介紹到這了,更多相關maven mirrors配置多個下載中心內容請搜尋我們以前的文章或繼續瀏覽下面的相關文章希望大家以後多多支援我們!