- 下載
下載地址:https://archive.apache.org/dist/maven/maven-3/,這裏下載apachemaven-3.5.0-bin.zip - 安裝
將apache-maven-3.5.0-bin.zip壓縮文件解壓到一個非中文且無空格的路徑文件夾內,這裏解壓到C:\Program_Files文件夾根目錄 - 配置
選擇此電腦,點擊屬性,選擇高級系統設置,選擇環境變量,
a、新建MAVEN_HOME環境變量,其值爲maven安裝根目錄,這裏爲C:\Program_Files\apache-maven-3.5.0
b、修改path環境變量,向該環境變量值內添加;%MAVEN_HOME%/bin
- 測試
打開DOS窗口,執行mvn -version命令,如果輸出諸如下圖信息則說明maven安裝成功:
- 配置存儲庫鏡像站點
a、使用Notepad++打開“Maven軟件根目錄\conf\settings.xml”文件,去掉152~157行代碼註釋,如下圖所示:
b、將上面mirror標籤進行如下修改:
<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>nexus</id>
<mirrorOf>*</mirrorOf>
<name>alibaba</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror> </mirrors>
有效url地址:
1、http://maven.aliyun.com/nexus/content/groups/public (推薦)
2、http://repository.sonatype.org/content/groups/public/
3、http://maven.oschina.net/content/groups/public/
4、https://maven.atlassian.com/repository/public/
5、http://repo1.maven.org/maven2/
6、http://mirrors.ibiblio.org/maven2/
- 拷貝settings.xml文件
a、DOS窗口執行mvn help:system命令,此時“C:\Users\計算機名”路徑中會創建一個名爲.m2的文件夾;
b、將“Maven軟件根目錄\conf\settings.xml”文件拷貝到“C:\Users\計算機名.m2”路徑中。