1 測試maven 是否已經安裝成功
mvn -version Apache Maven 3.3.3 (7994120775791599e205a5524ec3e0dfe41d4a06; 2015-04-22T07:57:3 7-04:00) Maven home: C:\apache-maven-3.3.3\bin\.. Java version: 1.7.0_75, vendor: Oracle Corporation Java home: C:\Java\jdk1.7.0_75\jre Default locale: en_US, platform encoding: Cp1252 OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"
如果現實上述信息證明安裝成功。
2 找出當前maven settings.xml 和 倉庫的位置
如果你有多個settings.xml 但是不清楚當前maven 是讀取哪個 可以執行如下指令
默認倉庫位置 $uer.home/.m2
mvn -X ... ... [DEBUG] Reading global settings from C:\apache-maven-3.3.3\bin\..\conf\settings. xml [DEBUG] Reading user settings from C:\Users\jian_j\.m2\settings.xml [DEBUG] Reading global toolchains from C:\apache-maven-3.3.3\bin\..\conf\toolcha ins.xml [DEBUG] Reading user toolchains from C:\Users\jian_j\.m2\toolchains.xml [DEBUG] Using local repository at C:\maven_repo [DEBUG] Using manager EnhancedLocalRepositoryManager with priority 10.0 for C:\m aven_repo
通過上述信息可以查看出是讀取哪個settings.xml 並且知道當前倉庫local repo 的位置
3 設置自定義倉庫位置
找到settings.xml 修改localRepository
< settings > <!-- localRepository | The path to the local repository maven will use to store artifacts. | | Default: ~/.m2/repository <localRepository>/path/to/local/repo</localRepository> --> < localRepository > 才:/maven_repo </ localRepository >