注:整理錯誤,不喜歡爲了一個小問題,佔篇幅,所以請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:
-
<property name="realm" ref="shiroDBRealm" />
-
<bean id="shiroDbRealm" class="com.tsxs.security.ShiroDbRealmUser"></bean>
-
配置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
解決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文件
解決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
解決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
此問題解決,也適合第三方無依賴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
解決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)
解決14:
-
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] 錯誤: 找不到符號
解決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" />
問題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下項目下的個各個文件中版本號
備註附件(解釋學習自網絡資料,非常感謝作者):
-
dependencyManagement:
-
Maven 使用dependencyManagement 元素來提供了一種管理依賴版本號的方式。通常會在一個組織或者項目的最頂層的父POM 中看到dependencyManagement 元素。使用pom.xml 中的dependencyManagement 元素能讓所有在子項目中引用一個依賴而不用顯式的列出版本號。Maven 會沿着父子層次向上走,直到找到一個擁有dependencyManagement 元素的項目,然後它就會使用在這個dependencyManagement 元素中指定的版本號。
-
如果有多個子項目都引用同一樣依賴,則可以避免在每個使用的子項目裏都聲明一個版本號,這樣當想升級或切換到另一個版本時,只需要在頂層父容器裏更新,而不需要一個一個子項目的修改 ;另外如果某個子項目需要另外的一個版本,只需要聲明version就可。
-
dependencyManagement裏只是聲明依賴,並不實現引入,因此子項目需要顯式的聲明需要用的依賴。
-
dependencies:
-
相對於dependencyManagement,所有聲明在dependencies裏的依賴都會自動引入,並默認被所有的子項目繼承。如果你要發佈同樣的代碼,但是由於技術原因需要生成兩個單獨的構件,你就要使用一個分類器(classifier)。
-
classifier:
-
如果你要發佈同樣的代碼,但是由於技術原因需要生成兩個單獨的構件,你就要使用一個分類器(classifier)。
-
例如,如果你想要構建兩個單獨的構件成JAR,一個使用Java 1.4 編譯器,另一個使用Java 6 編譯器,你就可以使用分類器來生成兩個單獨的JAR構件,它們有同樣的groupId:artifactId:version組合。
-
如果你的項目使用本地擴展類庫,你可以使用分類器爲每一個目標平臺生成一個構件。分類器常用於打包構件的源碼,JavaDoc 或者二進制集合。
問題17:only whitespace content allowed before start tag and not \u0 (position: START_DOCUMENT se……
解決17:刪除本地庫中所有文件,重新clean install.