1.1 Maven倉庫主要有2種:
-
remote repository:相當於公共的倉庫,大家都能訪問到,一般可以用URL的形式訪問,一般默認的地址:http://search.maven.org/
-
local repository:存放在本地磁盤的一個文件夾,例如,windows上默認是C:\Users\{用戶名}\.m2\repository目錄
1.2 Remote Repository主要有3種:
-
中央倉庫:http://repo1.maven.org/maven2/
-
私服:內網自建的maven repository,其URL是一個內部網址
-
其他公共倉庫:其他可以互聯網公共訪問maven repository,例如 jboss repository等
repository里存放的都是各種jar包和maven插件。當向倉庫請求插件或依賴的時候,會先檢查local repository,如果local repository有則直接返回,否則會向remote repository請求,並緩存到local repository。
也可以把做的東西放到本地倉庫,僅供本地使用;或上傳到遠程倉庫,供大家使用。
================================
我用的是idea自帶的maven3
下載安裝idea以后,最好先配置一些maven的環境變量,有一些操作要在cmd中進行
idea中的maven路徑為:
D:\Program Files (x86)\JetBrains\IntelliJ IDEA 2016.1.3\plugins\maven\lib\maven3
在環境變量中配置
MAVEN_HOME,變量值就是上面的路徑
再在Path中添加
%MAVEN_HOME%\bin;
這樣maven就配置好了。
maven默認的倉儲位置是C:\Users\Administrator\.m2
資源全放系統盤,萬一要重裝系統呢?現在切換到D盤
打開配置文件,位置為%MAVEN_HOME%/conf/setting.xml,maven_home可以查看idea中的maven設置
打開setting.xml,修改配置信息
<!-- localRepository | The path to the local repository maven will use to store artifacts. | | Default: ~/.m2/repository <localRepository>/path/to/local/repo</localRepository> --> <localRepository>D:\360CloudUI\maven\repository</localRepository>
最后就是把這個setting.xml配置文件覆蓋掉idea中默認的配置
一切ok,再把原來C盤中的repository資源遷移到新的位置就可以了。
===================================================================
maven 鏡像配置成國內的
同樣是在上面的setting.xml中進行配置
<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> --> <mirror> <id>CN</id> <name>OSChina Central</name> <url>http://maven.oschina.net/content/groups/public/</url> <mirrorOf>central</mirrorOf> </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>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>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>JBossJBPM</id> <mirrorOf>central</mirrorOf> <name>JBossJBPM Repository</name> <url>https://repository.jboss.org/nexus/content/repositories/releases/</url> </mirror> <mirror> <id>antelink</id> <mirrorOf>central</mirrorOf> <name>antelink Repository</name> <url>http://maven.antelink.com/content/repositories/central/</url> </mirror> <mirror> <id>openkoala</id> <mirrorOf>central</mirrorOf> <name>openkoala Repository</name> <url>http://nexus.openkoala.org/nexus/content/groups/Koala-release/</url> </mirror> <mirror> <id>tmatesoft</id> <mirrorOf>central</mirrorOf> <name>tmatesoft Repository</name> <url>http://maven.tmatesoft.com/content/groups/public/</url> </mirror> <mirror> <id>mavensync</id> <mirrorOf>central</mirrorOf> <name>mavensync Repository</name> <url>http://mavensync.zkoss.org/maven2/</url> </mirror> </mirrors>
阿里雲的
<mirror> <id>alimaven</id> <name>aliyun maven</name> <url>http://maven.aliyun.com/nexus/content/groups/public/</url> <mirrorOf>central</mirrorOf> </mirror>
http://blog.csdn.net/jiuqiyuliang/article/details/45390313
https://my.oschina.net/fdblog/blog/546938
http://www.tuicool.com/articles/VRJ3qui
https://my.oschina.net/sunchp/blog/100634