Maven系列筆記(二)—— Maven的本地倉庫、中央倉庫與私服
阿新 • • 發佈:2019-01-02
一、本地倉庫
Maven本地倉庫的預設位置為
C:\Users\Administrator.m2\repository
repository 即為倉庫,在專案構建時,Maven會自動向該資料夾下載專案所需jar包。
如果想設定其他位置可以在{MAVEN_HOME}\conf\setting.xml中新增如下程式碼設定倉庫位置為F:\repository
<settings><!-- localRepository
| The path to the local repository maven will use to store artifacts.
|
| Default: ~/.m2/repository
<localRepository>/path/to/local/repo</localRepository>
--> <localRepository>F:\repository</localRepository>
二、中央倉庫
由於該地址在國外,國內訪問會很慢,所以可以設定連線國內的私服。
三、私服
私服是私有伺服器,是公司內部Maven專案經常需要的。Nexus是常用的私用Maven伺服器,一般是公司內部使用。在連線中央倉庫過慢的情況下,建議使用網上國內的私服,推薦http://maven.aliyun.com/nexus
只需要在settings.xml中新增如下程式碼
<mirror>
<id>nexus-aliyun</id >
<mirrorOf>*</mirrorOf>
<name>Nexus aliyun</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>