http://blog.csdn.net/typa01_kk/article/details/49185759
Maven項目錯誤解決小結
注:整理錯誤,不喜歡為了一個小問題,占篇幅,所以請Ctrl+F自己查看,定位問題,願為解決.
注:網絡上的錯誤解決經驗,只是作者在特定的條件下發生,或者適合你不適合你,請勿責怪,若無解決答案,請你請教他人或耐心解決,可以記錄之后分享,我們愛分享,一起開始吧!
問題1:
-Dmaven.multiModuleProjectDirectory system propery is not set. Check $M2_HOME environment variable and mvn script match.
解決1:
可以設一個windows os's環境變量M2_HOME指向你的maven安裝目錄 M2_HOME=D:\Apps\apache-maven-3.3.1 然后在Window->Preference->Java->Installed JREs->Edit 在Default VM arguments中設置 -Dmaven.multiModuleProjectDirectory=$M2_HOME
問題2:
java.lang.ClassNotFoundException: org.springframework.web.util.IntrospectorCleanupListener /org.springframework.web.context.ContextLoaderListener
解決2:
選中項目->右鍵Properties->選擇Deployment Assemby->選擇Add->選中Java Build Path Entries->Next->選擇Maven Dependencies->Finish->Apply->OK
問題3:
The import com.tsxs.common.tool.ValidateCodeImg cannot be resolved
解決3:
Eclipse -> Project -> Clean... Ok.
問題4:
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'shiroDBRealm' is defined
解決4:
1 <property name="realm" ref="shiroDBRealm" /> 2 <bean id="shiroDbRealm" class="com.tsxs.security.ShiroDbRealmUser"> 3 </bean> 4 配置id和ref的大小寫不一致(ctrl+f搜索不區分大小寫一致).字母B/b.
問題5:
java project 轉換exchange maven project:
[ERROR] Plugin org.apache.maven.plugins:maven-jar-plugin:2.4 or one of its dependencies could not be resolved: Failure to find org.apache.maven.plugins:maven-jar-plugin:jar:2.4 in http://localhost:8081/nexus/content/groups/public was cached in the local repository, resolution will not be reattempted until the update interval of nexus has elapsed or updates are forced -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException
[ERROR] Plugin org.apache.maven.plugins:maven-jar-plugin:2.4 or one of its dependencies could not be resolved: Failure to find org.apache.maven.plugins:maven-jar-plugin:jar:2.4 in http://localhost:8081/nexus/content/groups/public was cached in the local repository, resolution will not be reattempted until the update interval of nexus has elapsed or updates are forced -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException
解決5:
在Convert to Maven Project的時候修改pom.xml下:<version>0.0.1-SNAPSHOT</version>到<version>0.0.1</version>后maven clean install.
問題6:
九月 13, 2015 1:20:48 上午 org.apache.catalina.core.StandardContext listenerStart
嚴重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from file
[D:\developer\softwares\servers\apache-tomcat-8.0.24\webapps\weloveshare\WEB-INF\classes\applicationContext-mybatis.xml];
nested exception is com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException: 3 字節的 UTF-8 序列的字節 3 無效。
Caused by: com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException: 3 字節的 UTF-8 序列的字節 3 無效。
error文件
嚴重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from file
[D:\developer\softwares\servers\apache-tomcat-8.0.24\webapps\weloveshare\WEB-INF\classes\applicationContext-mybatis.xml];
nested exception is com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException: 3 字節的 UTF-8 序列的字節 3 無效。
Caused by: com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException: 3 字節的 UTF-8 序列的字節 3 無效。
error文件
解決6:
最終解決: 1使用軟件"010 Editor是一個全新的十六進位文件編輯器"查看文件頭有亂碼,刪除保存就ok了. 2由於,我,重新整理的分區(雙系統),無奈下,我重新搭建了一個項目,復制代碼過去就ok了.
問題7:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4或Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin: 2.4..
解決7:
解決:重啟一下console-nexus.bat就好了,或刪除本地maven倉庫對應的包(涉及到的根包一起刪)
問題8:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
[ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/ModelParseException
[ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/ModelParseException
解決8:
dependency沒有在dependencies里面
問題9:
maven中加入新的:dependency在install的時候,報錯nexus沒有相應的jar包
解決9:
主要刪除本地maven的repositories下的相應位置jar的路徑,重新install就ok.
或者重啟nexus或沒有啟動nexus。
問題10:
Java Project轉maven project因為出錯沒有Maven Dependencies路徑
解決10:
工程右鍵:Maven->Disable Maven Nature
然后,再次重新轉maven:
Configure->Convert to Maven Project. ok!
注:一般不用重啟nexus服務器,除非由於進程端口占用或者服務停止,或者服務器關機或者死機,刪除本地相對應的路徑文件,clean install 則解決!
問題11:
設置pom.xml后,clean install編譯不報錯,就是不能加載Maven Dependencies和下載jar包
解決11:
因為<dependency>在<dependencies>中,但<dependencies>又在<dependencyManagement>中,刪除最外層的<dependencyManagement>后,clean install 則解決!區別解釋,備注附件!
問題12:
如果pom.xml中<dependency>標簽報錯畫紅線並報紅叉,錯誤:Missing artifact mycoding.kaka:kaka:jar:0.0.1
在Markers中報錯:
Description Resource Path Location Type
Missing artifact mycoding.kaka:kaka:jar:0.0.1 pom.xml /zJavaDemo line 20 Maven Dependency Problem
在Markers中報錯:
Description Resource Path Location Type
Missing artifact mycoding.kaka:kaka:jar:0.0.1 pom.xml /zJavaDemo line 20 Maven Dependency Problem
此問題解決,也適合第三方無依賴jar和本地擴展類加入maven統一管理
解決12:
1:如果為其他技術支持網站提供的的正確的依賴<dependency>,則刪除本地maven的repositories下的相應位置jar的路徑和所有文件,再clean install 則解決!
2: Maven自定義上傳第三方包到3rd party(第三方無依賴jar和本地擴展類加入maven統一管理)
1:如果為其他技術支持網站提供的的正確的依賴<dependency>,則刪除本地maven的repositories下的相應位置jar的路徑和所有文件,再clean install 則解決!
2: Maven自定義上傳第三方包到3rd party(第三方無依賴jar和本地擴展類加入maven統一管理)
問題13:
Description Resource Path Location Type
Project configuration is not up-to-date with pom.xml. Run Maven->Update Project or use Quick Fix. webproject line 1 Maven Configuration Problem
Description Resource Path Location Type
Project configuration is not up-to-date with pom.xml. Run Maven->Update Project or use Quick Fix. webproject line 1 Maven Configuration Problem
解決13:
項目上右鍵 ——> Maven ——> Update Project ……,打開一個(Update Maven Dependencies)的對話框,然后勾選住出錯的項目,點擊Ok
問題14:
Description Resource Path Location Type
Java compiler level does not match the version of the installed Java project facet. webproject Unknown Faceted Project Problem (Java Version Mismatch)
Description Resource Path Location Type
Java compiler level does not match the version of the installed Java project facet. webproject Unknown Faceted Project Problem (Java Version Mismatch)
解決14:
解決15:
workspace下本項目的.setting下org.eclipse.jdt.core.prefs文件(修改和jdk一致版本): eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 org.eclipse.jdt.core.compiler.compliance=1.8 org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning org.eclipse.jdt.core.compiler.source=1.8
問題15:
[ERROR] D:\DeveloperX\Code\Java\src\main\java\com\tsxs\module\utils\NetworkUtil.java:[3,25] 錯誤: 程序包javax.servlet.http不存在
[ERROR] D:\DeveloperX\Code\Java\src\main\java\com\tsxs\module\utils\NetworkUtil.java:[14,41] 錯誤: 找不到符號
[ERROR] D:\DeveloperX\Code\Java\src\main\java\com\tsxs\module\utils\NetworkUtil.java:[3,25] 錯誤: 程序包javax.servlet.http不存在
[ERROR] D:\DeveloperX\Code\Java\src\main\java\com\tsxs\module\utils\NetworkUtil.java:[14,41] 錯誤: 找不到符號
解決15:
項目右鍵 --> properties --> Java Build Path的libraries保證只有:JRE System Library[jdk1.8.0.66]和 Maven Dependencies
注:如果還有Apache Tomcat v8.0[Apache Tomcat v8.0]則,Remove刪除它,在pom.xml中添加以下依賴讓maven統一管理!
注:版本看自己jdk和tomcat版本
<!-- servlet/jsp -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.2</version>
</dependency>
需要注意的配置:







問題15擴展:頁面無controller處理跳轉也需要15解決!
<!-- 容器默認的DefaultServletHandler處理 所有靜態內容與無RequestMapping處理的URL -->
<mvc:default-servlet-handler />
<!-- 定義無需Controller的url<->view直接映射 -->
<mvc:view-controller path="/" view-name="redirect:/index.html" />
<!-- 容器默認的DefaultServletHandler處理 所有靜態內容與無RequestMapping處理的URL -->
<mvc:default-servlet-handler />
<!-- 定義無需Controller的url<->view直接映射 -->
<mvc:view-controller path="/" view-name="redirect:/index.html" />
問題16:Description Resource Path Location Type
One or more constraints have not been satisfied. webproject line 1 Maven Java EE Configuration Problem
提示16:查看項目的jdk和compiler和eclipse工作空間workspace下項目下的個各個文件中版本號
One or more constraints have not been satisfied. webproject line 1 Maven Java EE Configuration Problem
提示16:查看項目的jdk和compiler和eclipse工作空間workspace下項目下的個各個文件中版本號
