一、Eclipse中配置Maven:
1、配置 Eclipse 中的 maven 环境:
Window -> Preference -> Maven -> Installation -> Add(选择Maven的安装目录);
选中新导入的maven;
2、设置 maven 的 setting.xml 文件路径:
Window -> Preference -> Maven -> Installation -> Browser(选择 Maven安装目录\conf\settings.xml);
配置 settings.xml 中的“<localRepository><\localRepository>",配置 maven 本地库的存储位置;
二、Eclipse 导入maven项目时,pom.xml 可能有的问题:
1、org.codehaus.plexus.archiver.jar.Manifest.merge(org.codehaus.plexus.archiver.jar.Manifest)
错误原因: m2eclipse-mavenarchiver 通过反射方法调用 mavenarchiver 插件中的 merge() 方法,而该方法在 mavenarchiver 2.4 中已被移除,所以调用失败。
解决方法:升级 m2eclipse-mavenarchiver。升级地址:http://repo1.maven.org/maven2/.m2e/connectors/m2eclipse-mavenarchiver/0.17.0/N/LATEST/
eclipse 安装/更新插件的方法:启动Eclipse之后,在菜单栏中选择Help,然后选择Install New Software…,接着你会看到一个Install对话框,点击Work with:字段边上的Add按钮,你会得到一个新的Add Repository对话框,在Name字段中输入m2e,Location字段中输入(链接),然后点击OK。Eclipse会下载m2eclipse安装站点上的资源信息
2、Plugin execution not covered by lifecycle configuration
错误原因:
解决方法1:<plugins> 标签外再套一个 <pluginManagement> 标签
<build>
<pluginManagement>
<plugins>
<plugin> ... </plugin>
<plugin> ... </plugin>
....
</plugins>
</pluginManagement>
</build>
官方借给出的解决方法:http://wiki.eclipse.org/M2E_plugin_execution_not_covered
三、Eclipse中build pom.xml时可能遇到的问题:
1、-Dmaven.multiModuleProjectDirectory system propery is not set. Check $M2_HOME environment variable and mvn script match.
ps:$M2_HOME 是旧版本 Maven 中配置的环境变量;
解决方法:Window->Preference->Java->Installed JREs->Edit;
在Default VM arguments中设置:-Dmaven.multiModuleProjectDirectory=$M2_HOME($MAVEN_HOME,maven的环境变量)
2、No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
原因:maven build pom.xml 时,需要的是jdk的环境,但是Eclipse提供的是 jre环境
解决方法:Eclipse->Window->Preferences->Java->Installed JREs -> Add 将jdk 添加到环境中