關於Maven報錯的一些解決辦法(別處貼的)
1、警告:The tag handler class for "s:form"(org.apache.struts2.views.jsp.ui.FormTag) was not found on the Java Build Path
這個問題終於可以解決了,在出問題的頁面 <s:form> 標簽前後刪除空格後保存文件警告即可消失,即<s:form>為改行的起始,然後保存。
2、Eclipse下java compiler level does not match the version of theinstalled Java project facet的問題 .
javacompilerfaceteclipsepropertiesjdk問題現象:項目圖標報錯“Java compiler level does not match the version of theinstalled Java project facet.”。
分析原因:根據錯誤信息的字面意思,應該是Java版本設定不一致的問題。而且這個Java版本跟Project安裝的有關系。
解決辦法:
既然是project出的問題,自然要從項目屬性入手。其實很簡單,
修改項目的org.eclipse.wst.common.project.facet.core.xml
<installed facet="jst.web"version="2.5"/> --Dynamic Web Moudle Version
<installed facet="java"version="1.5"/> --java Version
根據自身機器開發環境設置
或者
右鍵項目“Properties”,在彈出的“Properties”窗口左側,單擊“Project Facets”,打開“Project Facets”頁面。
在頁面中的“Java”下拉列表中,選擇“1.5”
3、Struts2 + spring
需要在pom.xml中加入:
<!-- struts2 spring plugins -->
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-spring-plugin</artifactId>
<version>2.3.16</version>
</dependency>
同時在struts.xml中加入
<!-- 將Action交給spring容器管理 -->
<constant name="struts.objectFactory"value="spring" />
4、Eclipse : An error occurred while filtering resources
解決:Maven ->Update Project... resolved this problem for me
5、org.dom4j.DocumentException:Software caused connection abort:recv failed
這個錯誤有可能是hibernate的配置文件.hbm.xml裏
<!DOCTYPE hibernate-mapping PUBLIC"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
這個聲明有問題
用下面這個解決問題
<!DOCTYPE hibernate-mapping PUBLIC"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.NET/hibernate-configuration-3.0.dtd">
如果不行,則是顛倒過來,即如果原來使用
<!DOCTYPE hibernate-mapping PUBLIC"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
則用
<!DOCTYPE hibernate-mapping PUBLIC"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
6、Cannot change version of project facet Dynamic Web Module to3.0. 和 One or more constraints have not been satisfied.
需要修改 project的 properties的 project facts的 Dynamic Web Moudle Version版本和 web.xml中的版本一直,然後在通過maven update
以下為 web.xml的各個版本:
web.xml v2.3
[xml] view plaincopy
1. <?xml version="1.0" encoding="ISO-8859-1"?>
2. <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
3.
4. <web-app>
5.
6. </web-app>
web.xml v2.4
[xml] view plaincopy
1. <?xml version="1.0" encoding="UTF-8"?>
2. <web-app id="WebApp_9" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4. xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
5.
6. </web-app>
web.xml v2.5
[xml] view plaincopy
1. <?xml version="1.0" encoding="UTF-8"?>
2. <web-app xmlns=<a target="_blank" href="http://java.sun.com/xml/ns/javaee">http://java.sun.com/xml/ns/javaee</a>
3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4. xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
5. version="2.5">
6.
7. </web-app>
web.xml v3.0
[xml] view plaincopy
1. <?xml version="1.0" encoding="UTF-8"?>
2.
3. <web-app
4. version="3.0"
5. xmlns="http://java.sun.com/xml/ns/javaee"
6. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
7. xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
8.
9. </web-app>
7、An internal error occurred during:"Updating MavenProject"
(
mvn archetype:generate -DgroupId=com.mkyong -DartifactId=HibernateExample -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
) --java application
(
mvn archetype:generate -DgroupId=com.mkyong -DartifactId=HibernateExample -DarchetypeArtifactId=maven-archetype-webapp -DinteractiveMode=false
) --java web application
命令行創建 maven 項目轉為 eclipse項目時,在eclipse中打開存在的maven項目,不能通過 maven update解決:
問題提示:An internal error occurred during:"Updating MavenProject"
解決:
1、把該項目從eclipse中刪除,不要刪除掉項目文件(只是從eclipse項目視圖中刪除);
2、進入cmd ,然後進入到該項目目錄下比如:E:\workspace\mavenProject ,其中mavenProject為項目名稱;
3、執行命令:mvneclipse:clean;
4、檢查項目目中是否還存在 .classpath、.project、.settings ,如果存在,則刪除掉;
5、通過右鍵-->import-->Existing Maven Projects,重新導入即可。
8、
hibernate java.lang.UnsupportedOperationException: The user must supply a JDBC connection
是 hibernate的配置文件hibernate.cfg.xml配置存在問題,檢查數據連接的driver_class、url、username、root等參數名及參數值是否正確
9、MySQL 中,如果hibernate的主鍵用 uuid.hex,報異常如下:
java.sql.BatchUpdateException: Data truncation: Data too longfor column ‘SID‘ at row 1 .
解決:
修改mysql的字符集和創建表的一樣即可,比如創建表 create table aa() default charset=utf8 ;
那麽通過命令:set names utf8 ; ,修改 mysql的字符集;
重新運行程序即可。
10、maven 在 eclipse中創建maven project報一下錯誤解決:
Could not resolvearchetypeorg.apache.maven.archetypes:maven-archetype-quickstart:RELEASE fromany of theconfigured repositories.
Could not resolve artifact
Failed to resolve versionfororg.apache.maven.archetypes:maven-archetype-quickstart:pom:RELEASE: Couldnotfindmetadataorg.apache.maven.archetypes:maven-archetype-quickstart/maven-metadata.xmlinlocal (E:\maven3\repository)
Failed to resolve versionfororg.apache.maven.archetypes:maven-archetype-quickstart:pom:RELEASE: Couldnotfindmetadataorg.apache.maven.archetypes:maven-archetype-quickstart/maven-metadata.xmlinlocal (E:\maven3\repository)
解決思路:
a、修改conf/settings.xml,在<mirrors>…</mirror>中間加入以下內容:
<mirror>
<id>ibiblio.org</id>
<name>ibiblio Mirror ofhttp://repo1.maven.org/maven2/</name>
<url>http://mirrors.ibiblio.org/pub/mirrors/maven2</url>
<mirrorOf>central</mirrorOf>
<!-- UnitedStates, North Carolina-->
</mirror>
<mirror>
<id>cica.es</id>
<url>http://ftp.cica.es/mirrors/maven2</url>
<mirrorOf>central</mirrorOf>
<!-- Spain,Sevilla -->
</mirror>
<mirror>
<id>skynet.be</id>
<url>http://maven2.mirrors.skynet.be/pub/maven2</url>
<mirrorOf>central</mirrorOf>
<!-- Belgium-->
</mirror>
b、如果機器使用代理,則需要修改代理信息,在<proxies>…</proxies>之間加入
<proxy>
<id>my-proxy</id> <!—起一個名字-->
<active>true</active> <!—固定為true-->
<protocol>http</protocol><!—固定為http-->
<username>user</username><!—如果不需要設置,則屏蔽掉username屬性—>
<password>pwd</password><!—如果不需要設置,則屏蔽掉password屬性—>
<host>10.17.75.2</host><!—代理服務器地址-->
<port>3128</port><!—代理服務器端口-->
<nonProxyHosts>localhost|127.0.0.1</nonProxyHosts>
</proxy>
11、eclipse 執行 mvn install的時候報如下錯誤
[ERROR] Failed to parse plugin descriptor fororg.apache.maven.plugins:maven-install-plugin:2.3.1(E:\maven3\repository\org\apache\maven\plugins\maven-install-plugin\2.3.1\maven-install-plugin-2.3.1.jar):error in opening zip file -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -eswitch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, pleaseread the following articles:
[ERROR] [Help 1]http://cwiki.apache.org/confluence/display/MAVEN/PluginDescriptorParsingException
解決方法:
刪除:E:\maven3\repository\org\apache\maven\plugins\maven-install-plugin\2.3.1目錄,操作後:E:\maven3\repository\org\apache\maven\plugins\maven-install-plugin\下沒有2.3.1目錄,然後重新執行 mvn Install ;
如果執行 mvn Clear存在相同問題,這只需要刪除對應的目錄,讓Maven重新下載對應的jar即可。
Cannot change version of project facet Dynamic Web Module to 3.1 (Eclipse Maven唯一解決方案)
If you want to use version 3.1 you need to use the following schema:
- http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd
Note that 3.0 and 3.1 are different: in 3.1 there‘s no Sun mentioned, so simply changing 3_0.xsd to 3_1.xsd won‘t work
de><?xml version="1.0" encoding="UTF-8"?><web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee"></web-app>de>
Also, make sure you‘re depending on the latest versions in your pom.xml. That is,
de><plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <version>2.4</version> <configuration> ... </configuration></plugin>de>
and
de><dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>3.1.0</version> <scope>provided</scope></dependency>de>
Also, you should compile with Java 7 or 8:
de><plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.1</version> <configuration> <source>1.7</source> <target>1.7</target> </configuration></plugin>de>
關於Maven報錯的一些解決辦法(別處貼的)