首先要注意Maven3.x以上版本要求安装jdk1.7以上版本
下载最新版的安装包:http://maven.apache.org/download.cgi
我的安装到了E:\Program Files\apache-maven-3.5.3
变量名:MAVEN_HOME
变量值:E:\Program Files\apache-maven-3.5.3
变量名:Path
变量值:%MAVEN_HOME%\bin
注意:如果是在一行里面编辑,请以英文分号结尾,WIN10系统编辑方式不同,所以不需要后面添加英文分号
打开cmd,输入:mvn -version 或者 mvn -v,出现以下信息标识maven环境配置成功
本地仓库默认C:\Users\用户名.m2 目录下,我们换个指定的位置存放,打开maven安装目录\conf\setting.xml
文件,找到<localRepository>,修改为我们自己指定的路径
默认的是国外的仓库,这样速度会很慢,我们配置几个速度较快的maven仓库,打开maven安装目录
\conf\setting.xml 文件,在mirrors下添加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>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>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
<mirror>
<id>central</id>
<name>central</name>
<url>http://central.maven.org/maven2/</url>
<mirrorOf>central</mirrorOf>
</mirror>
<mirror>
<id>apache</id>
<name>apache maven</name>
<url>https://repository.apache.org/content/repositories/releases/</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
下一步
Default VM arguments 后面添加以下内容:
-Dmaven.multiModuleProjectDirectory=$M2_HOME
原文:http://blog.51cto.com/1197822/2315306