maven安装
转自:http://www.cnblogs.com/happyframework/p/3391691.html
1. 下载
地址:http://maven.apache.org/。解压缩,比如放在D:\Program Files\apache-maven-3.0.4处。
2. 环境变量配置
配置环境变量 MAVEN_HOME=D:\Program Files\apache-maven-3.0.4 把MAVEN_HOME加入到PATH中 xxxx;%MAVEN_HOME%\bin
保存后,在控制台中输入mvn -version。若能输出版本信息,则maven安装成功。
3. maven仓库配置
maven仓库是用来放置下载到的各种Jar包的。
在D:\Program Files\apache-maven-3.0.4\conf下面找到settings.xml 配置maven的仓库(当然可以默认)
<!-- localRepository
| The path to the local repository maven will use to store artifacts.
|
| Default: ${user.home}/.m2/repository
<localRepository>/path/to/local/repo</localRepository>
-->
<localRepository>D:/Program Files/apache-maven-3.0.4/repositories</localRepository>
5. maven镜像配置
maven镜像用来配置从哪里下载jar包。settings.xml中默认的镜像地址可能下载Jar包比较慢,可以自已配置下载快的镜像地址。比如:
D:\Program Files\apache-maven-3.0.4\conf\settings.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>repo2</id>
<mirrorOf>central</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://repo2.maven.org/maven2/</url>
</mirror>
<mirror>
<id>net-cn</id>
<mirrorOf>central</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://maven.net.cn/content/groups/public/</url>
</mirror>
<mirror>
<id>ui</id>
<mirrorOf>central</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://uk.maven.org/maven2/</url>
</mirror>
<mirror>
<id>ibiblio</id>
<mirrorOf>central</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://mirrors.ibiblio.org/pub/mirrors/maven2/</url>
</mirror>
<mirror>
<id>jboss-public-repository-group</id>
<mirrorOf>central</mirrorOf>
<name>JBoss Public Repository Group</name>
<url>http://repository.jboss.org/nexus/content/groups/public</url>
</mirror>
</mirrors>
6. maven 的两份settings.xml
settings.xml存在于两个地方:
1.安装的地方:D:\Program Files\apache-maven-3.0.4\conf\settings.xml
2.用户的目录:${user.home}/.m2/settings.xml
前者又被叫做全局配置,后者被称为用户配置。如果两者都存在,它们的内容将被合并,并且用户范围的settings.xml优先。

浙公网安备 33010602011771号