Maven问题记录
各人处理方式不一样,适合自己才是最好的
问题1:
Dmaven.multiModuleProjectDirectory system property is not set.
Check $M2_HOME environment variable and mvn script match
解决1:
缺少M2_HOME的环境变量,需要添加
Preference->Java->Installed JREs->Edit 选择你正在使用的jdk,点击编辑
添加如下内容(前面的横杠不要漏了)
-Dmaven.multiModuleProjectDirectory=$M2_HOME
问题2:
Could not resolve archetype org.apache.maven.archetypes:
maven-archetype-webapp
解决2:
其实就是找不到这个acrchetype_webapp,要创建一个基于maven结构的工程,但是找不到这个工程的模板,所以就报错了,既然找不到,就手动给他找到好了
文档参考地址:
http://maven.apache.org/archetype/maven-archetype-plugin/specification/archetype-catalog.html
archetype-webappxml地址:
http://repo.maven.apache.org/maven2/archetype-catalog.xml
找到windows-preference-maven-archetype-add remote catalog
添加你的catalog地址
重新创建maven工程,选择你刚才的catalog,选择maven-archetype-webapp用户
问题3:
org.apache.maven.archiver.MavenArchiver.getManifest(org.apache.maven.project.MavenProject, org.apache.maven.archiver.MavenArchiveConfiguration)
解决3:
问题6:
pom报错,报错如下,看报错信息,是连接服务器下载jar包失败,需要手动处理下
Multiple annotations found at this line:
- Missing artifact org.slf4j:slf4j-api:jar:1.7.21
- Missing artifact org.apache.tomcat.embed:tomcat-embed-el:jar:8.5.4
- ArtifactTransferException: Could not transfer artifact com.fasterxml.jackson.core:jackson-databind:jar:2.8.1 from/to central (http://
repo.maven.apache.org/maven2): No response received after 60000
- ArtifactTransferException: Could not transfer artifact org.slf4j:slf4j-api:jar:1.7.21 from/to central (http://repo.maven.apache.org/maven2): No
response received after 60000
- ArtifactTransferException: Could not transfer artifact com.fasterxml.jackson.core:jackson-core:jar:2.8.1 from/to central (http://
repo.maven.apache.org/maven2): No response received after 60000
- Missing artifact com.fasterxml.jackson.core:jackson-core:jar:2.8.1
- Missing artifact com.fasterxml.jackson.core:jackson-databind:jar:2.8.1
- ArtifactTransferException: Could not transfer artifact org.apache.tomcat.embed:tomcat-embed-el:jar:8.5.4 from/to central (http://
repo.maven.apache.org/maven2): No response received after 60000
- Missing artifact org.apache.tomcat.embed:tomcat-embed-core:jar:8.5.4
- ArtifactTransferException: Could not transfer artifact org.apache.tomcat.embed:tomcat-embed-core:jar:8.5.4 from/to central (http://
repo.maven.apache.org/maven2): No response received after 60000
解决6:
按上面信息的提示,缺失的是下面3个jar,所以百度下载即可
tomcat-embed-el.jar,版本8.5.4,文件夹层级org.apache.tomcat.embed
org.slf4j:slf4j-api.jar,版本1.7.21,文件夹层级org.apache.tomcat.embed
jackson-core.jar,版本2.8.1,文件夹层级com.fasterxml.jackson.core
下载的方法:
比如这个地址http://maven.outofmemory.cn/,如下图,搜索你要的名称即可
随便找一个版本,点击进去
在这里找到你要的版本就好了,如果这里没有,百度吧骚年
下载之后:
文件夹层级指的是你下载了这个jar之后,要放到哪里
maven在本地会有一个放jar 的仓库,比如jackson-core.jar
我的地址是C:\Users\iamzh.m2\repository\com\fasterxml\jackson\core\jackson-core\2.8.1
先删除那个lastupdated,再将你下载的jar复制到此文件夹即可
不知道自己的maven本地仓库在哪,按如下截图找
复制了之后,怎么刷新?
我用粗暴的方法,删除下面的所有信息,重新clean一下
问题7:
Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project iamzwhui.hellohui: Compilation failure
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
解决7:
项目右击选择buildpath,选择configure build path
先remove旧的jre system library,再添加新的
选择jre system library
选择工作空间默认或者其他,随自己情况,点击完成即可,我选择最后一个
但是这个时候它还是显示jre,这个不行,要找一个jdk的目录
windows–preference–java–installed jres,add进去,
找自己的jdk目录,下面的jre name会自动带出的,
记得installed jres页面要选择你刚才增加的那个jdk,点击完成保存,
这个时候你再项目右击选择buildpath,选择configure build path,
里面已经变为jdk了
问题8:
Failed to read artifact descriptor for org.eclipse.aether:aether-impl:jar:1.0.2.v20150114:
Could not transfer artifact org.eclipse.aether:aether-impl:pom:1.0.2.v20150114 from/to central
(http://repo.maven.apache.org/maven2):
connection timed out to
http://repo.maven.apache.org/maven2/org/eclipse/aether/aether-impl/1.0.2.v20150114/aether-impl-1.0.2.v20150114.pom -> [Help 1]
解决8:
还是下载失败,自己动手下载呗(参考问题7)
http://mvnrepository.com/artifact/org.eclipse.aether/aether-impl
问题10:
a pom xml file already exists in the destination folder
解决10:
相同Group id的项目已经存在
要么你当前项目改名称
要么干掉存在的项目
问题11:
xxx overlaps the workspace location xxx
解决11:
这个勾选不要去掉
问题12:
cvc-complex-type.2.4.a:
Invalid content was found starting with element XXXX
解决12:
往头部的xmlns:xsi中添加下面内容
http://www.springmodules.org/schema/cache/springmodules-cache.xsd http://www.springmodules.org/schema/cache/springmodules-ehcache.xsd
我的加完之后是这样的:
xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance http://www.springmodules.org/schema/cache/springmodules-cache.xsd http://www.springmodules.org/schema/cache/springmodules-ehcache.xsd”
问题13:
Resource Path Location Type
Java compiler level does not match the version of the installed Java project facet.
xxx
Unknown Faceted Project Problem (Java Version Mismatch)
解决13:
项目右键选择properties,
找到project facets
找到java,右键选择change version
选择你当前项目对应的版本即可
再refresh一下项目
当前项目对应的版本在这里看或者调整
上面截图与下面截图设置为一致即可
待续
下一篇: zookeeper的安装与启动