maven(版本3.3.1)构建项目时碰到的几个问题:
1 maven install时报:Dmaven.multiModuleProjectDirectory system propery is not set. Check $M2_HOME
解决方案:
①可以设一个环境变量MAVEN_HOME指向你的maven安装目录MAVEN_HOME=D:Appsapache-maven-3.3.1
②然后在Window->Preference->Java->Installed JRES->Edit在Default VM arguments中设置
-Dmaven.multiModuleProjectDirectory=$MAVEN _HOME,如图所示:
2 maven install时报:
Downloading:https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-compiler-plugin/3.1/maven-compiler-plugin-3.1.jar
解决方案:
① 打开maven配置文件(maven安装目录下的conf目录下的settings.xml文件)
② 搜索mirrors关键字,如果注释说明的下方没有 <mirrors>节点,则建立mirrors节点,带mirrors节点的所有配置如下(复制下面的内容,粘贴到配置文件中即可)
<mirror>
<id>ibiblio.org</id>
<name>ibiblio Mirror of http://repo1.maven.org/maven2/</name>
<url>http://mirrors.ibiblio.org/pub/mirrors/maven2</url>
<mirrorOf>central</mirrorOf>
<!-- United States, North Carolina -->
</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>
③ maven clean 对项目进行clean
④ 再次执行maven install
3 maven install时报:
Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:2.6…
细看后续错误提示信息:
Failed to collect dependencies at
org.apache.maven.plugins:maven-resources-plugin:jar:2.6
解决方法:
① 重新检查build path中JRE System Library 中引用的是不是jdk1.7以上版本;
② 保证JRE System Library的Refference是jdk中的jre.
4 maven clean 后再次执行 maven install,报错:
Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:2.6…
细看后续错误提示信息:
Access denied to:
http://mirrors.ibiblio.org/pub/mirrors/maven2/org/codehaus/plexus/plexus-classworlds/2.2.2/plexus-classworlds-2.2.2.jar
原来是镜像在这儿访问不了,从settings.xml中将前面所加镜像删除(前面所需包download已完成).
5 maven clean 后再次执行 maven install,报错:
javax.servlet.http不存在
解决方法:
将tomcat lib 目录下的 servlet-api.jar 复制到 jdk1.7.0_09jrelibext目录下,凡是出现找不到包的情况,都可以将找到的包放到jdk1.7.0_09jrelibext下。
6 maven install
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8.716 s
[INFO] Finished at: 2015-07-19T17:08:31+08:00
[INFO] Final Memory: 21M/225M
[INFO] ------------------------------------------------------------------------
项目构建打包成功!