本文轉載至http://blog.csdn.net/ko289830707/article/details/53559052
現在maven項目非常流行,因為它對jar實行了一個非常方便的管理,我們可以通過在pom.xml文件中做對應的配置即可將所需要的jar包與自己的項目形成依賴。
但是通常我們會因為下載jar包速度緩慢而苦惱,這十分影響開發效率,以及程序員的心情,在IDE下載jar時,無法對IDE做任何動作,只能大眼對小眼。
下載jar速度慢究其原因就是因為很多資源都是國外的,我們下載一個小文件幾乎就跨越了一個太平洋那么遠,那么有什么方法可以讓下載速度變快呢?
其實方法很簡單:maven是支持鏡像的,我們可以在maven的conf文件加下的setting.xml文件中找到<mirrors></mirrors>標簽
- <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>
- <id>mirrorId</id>
- <mirrorOf>repositoryId</mirrorOf>
- <name>Human Readable Name for this Mirror.</name>
- <url>http://my.repository.com/repo/path</url>
- </mirror>
- -->
- </mirrors>
在這個標簽中加入國內的鏡像即可,在這里推薦阿里雲的鏡像,下載速度有明顯的加快
- <mirror>
- <id>alimaven</id>
- <mirrorOf>central</mirrorOf>
- <name>aliyun maven</name>
- <url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
- </mirror>