1、maven下载地址:http://maven.apache.org/download.cgi,选择apache-maven-3.1.1-bin.tar.gz(示例)
2、下载完成后解压到本地,然后移动到自己的文件目录下(目录名最好纯英文)
我的:D:\Program\apache-maven-3.1.1
3、配置环境变量
(1)新加环境变量 MAVEN_HOME,值为 D:\Program\apache-maven-3.1.1
(2)配置Path环境变量,追加%MAVEN_HOME%\bin\;
4、环境变量配置完成,使用 mvn -v 命令检查配置是否成功,若成功会出现maven相关信息
5、配置本地仓库
在D:\Program\apache-maven-3.1.1\conf下找到settings.xml,修改其中localRepository,将他修改为本地仓库位置
<localRepository>D:\.m2\repository</localRepository>
6、运行命令 mvn help:system,若成功会有提示信息,新版本的maven不包含基础jar包,运行命令会检查并下载jar包,由于网络原因,相当慢,若果下载没有反应,可重新执行命令,或者自行下载jar包及相关文件
7、默认的镜像地址是国外的,有的网络下特别的慢,建议换成国内的镜像,更改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>alimaven</id>
<mirrorOf>central</mirrorOf>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
</mirror>
<!-- maven镜像 -->
<mirror>
<id>Central</id>
<url>https://repo1.maven.org/maven2</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>