下载地址
http://maven.apache.org/download.cgi
在线文档
http://maven.apache.org/ref/3.0.5/
安装
一.安装JDK,配置好JAVA_HOME,配置好PATH
测试
打开cmd
echo %Java_Home%
java -version
二.安装配置manen
1 将下载回来的包解压到任意地址,我的路径是D:\Program Files\apache-maven-3.0.5
2 新建环境变量M2_HOME 指向D:\Program Files\apache-maven-3.0.5
3 在path尾部添加%M2_HOME%\bin
4 检查是否安装成功
打开cmd
echo %M2_HOME%
mvn –v
(mvn -version)
配置文件
D:\Program Files\apache-maven-3.0.5\conf\settings.xml
可配置repository,默认是:用户目录\.m2\repository
--可配置为<localRepository>${env.M2_HOME}/repository</localRepository>
执行mvn help:system
这时候 maven 就会从远程仓库开始下载一大堆的东西,没事,让它下载着,迟早都要下载的。
(默认情况下,~/.m2目录下除了repository仓库之外就没有其他目录和文件了,不过大多数Maven用户需要复制M2_HOME/conf/settings.xml文件到~/.m2/settings.xml。这是一条最佳实践)
三.Eclipse安装maven的插件 m2eclipse
1 打开eclipse
2 Help – Install New Software
Add
m2e
http://m2eclipse.sonatype.org/sites/m2e
此路径已改为以下路径
http://download.eclipse.org/technology/m2e/releases
报错:
Cannot complete the install because one or more required items could not be found.
Software being installed: m2e - slf4j over logback logging (Optional) 1.4.0.20130601-0317 (org.eclipse.m2e.logback.feature.feature.group 1.4.0.20130601-0317)
Missing requirement: Maven Integration for Eclipse 1.4.0.20130601-0317 (org.eclipse.m2e.core.ui 1.4.0.20130601-0317) requires 'bundle org.slf4j.api 1.6.2' but it could not be found
Cannot satisfy dependency:
From: m2e logback appender 1.4.0.20130601-0317 (org.eclipse.m2e.logback.appender 1.4.0.20130601-0317)
To: bundle org.eclipse.m2e.core.ui [1.4.0,1.5.0)
Cannot satisfy dependency:
From: m2e - slf4j over logback logging (Optional) 1.4.0.20130601-0317 (org.eclipse.m2e.logback.feature.feature.group 1.4.0.20130601-0317)
To: org.eclipse.m2e.logback.appender [1.4.0.20130601-0317]
三、安装时出现问题:
直接在线安装maven2 会出现依赖插件找不到的问题,无法安装。必须先安装gef 插件后才能安装m2eclipse-core 插件,然而安装m2eclipse-extras 插件又依赖subclipse 插件。所以,三个插件的正确的安装顺序是:gef插件 》subclipse插件 》m2eclipse插件。
m2eclipse-core插件 ——依赖——>gef插件
m2eclipse-extras插件 ——依赖——>subclipse插件
可能需要先安装gef插件和svn插件
1.4.1 先安装GEF插件
maven插件安装的时辰会依附这个插件,在Eclipse -> help -> Install New SoftWare中安装,
gef
http://download.eclipse.org/tools/gef/updates/interim/
1.4.2 安装SVN插件
在Eclipse -> help -> Install New SoftWare中安装, site:http://subclipse.tigris.org/_1.6.x
安装完gef
还是报错:
Cannot complete the install because one or more required items could not be found.
Software being installed: m2e - Maven Integration for Eclipse 1.4.0.20130601-0317 (org.eclipse.m2e.feature.feature.group 1.4.0.20130601-0317)
Missing requirement: async-http-client 1.6.5.20130531-2315 (com.ning.async-http-client 1.6.5.20130531-2315) requires 'package org.slf4j 1.6.2' but it could not be found
Cannot satisfy dependency:
From: Maven Archetype Common Bundle 1.4.0.20130531-2315 (org.eclipse.m2e.archetype.common 1.4.0.20130531-2315)
To: bundle org.eclipse.m2e.maven.runtime [1.4.0,1.5.0)
Cannot satisfy dependency:
From: m2e - Maven Integration for Eclipse 1.4.0.20130601-0317 (org.eclipse.m2e.feature.feature.group 1.4.0.20130601-0317)
To: org.eclipse.m2e.archetype.common [1.4.0.20130531-2315]
Cannot satisfy dependency:
From: Embedded Maven Runtime Bundle 1.4.0.20130531-2315 (org.eclipse.m2e.maven.runtime 1.4.0.20130531-2315)
To: bundle com.ning.async-http-client [1.6.5,1.6.6)
离线安装包:
http://ishare.iask.sina.com.cn/f/36090147.html
在dropins目录下创建文件夹maven3
把解压出的features目录和plugins目录放到dropins下的maven3里就可以了,不用link方式。
目录
eclipse3.7
--plugins
--features
--links
------xxx.link(或者是xxx.txt)
--dropins
------xxx
----------plugins
----------features
测试
windows--首选项中有Maven