maven倉庫中心mirrors配置多個下載中心(執行最快的映象)
阿新 • • 發佈:2019-01-11
在日常生活中,我們使用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。
設定多個映象只會識別第一個映象下載jar包。配置的多個mirror可以都放著不影響,選取一個映象下載比較快的放在第一個就行。