maven + eclipse 問題記錄

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 the installed Java project facet的問題 .

javacompilerfaceteclipsepropertiesjdk問題現象:項目圖標報錯“Java compiler level does not match the version of the installed 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 to 3.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 version="1.0" encoding="ISO-8859-1"?>  
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">  
   
<web-app>  
   
</web-app>  

 

web.xml v2.4

<?xml version="1.0" encoding="UTF-8"?>  
<web-app id="WebApp_9" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"   
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">  
   
</web-app> 


web.xml v2.5

<?xml version="1.0" encoding="UTF-8"?>   
<web-app xmlns=<a target="_blank" href="http://java.sun.com/xml/ns/javaee">http://java.sun.com/xml/ns/javaee</a>   
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"   
version="2.5">  
   
</web-app>  


web.xml v3.0

<?xml version="1.0" encoding="UTF-8"?>  
   
<web-app  
        version="3.0"  
        xmlns="http://java.sun.com/xml/ns/javaee"  
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">  
   
</web-app>  

 

 

7、An internal error occurred during:"Updating Maven Project"

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 Maven Project"
解決:
1、把該項目從eclipse中刪除,不要刪除掉項目文件(只是從eclipse項目視圖中刪除);
2、進入cmd ,然後進入到該項目目錄下比如:E:\workspace\mavenProject ,其中mavenProject爲項目名稱;
3、執行命令:mvn eclipse: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 long for column 'SID' at row 1 .

解決:
  修改mysql的字符集和創建表的一樣即可 ,比如創建表 create table aa() default charset=utf8 ;
  
  那麼通過命令:set  names utf8 ; ,修改 mysql的字符集;

重新運行程序即可。

 

 

10、maven  eclipse中創建maven project報一下錯誤解決:

Could not resolve archetypeorg.apache.maven.archetypes:maven-archetype-quickstart:RELEASE from any of theconfigured repositories.

Could not resolve artifact

Failed to resolve version fororg.apache.maven.archetypes:maven-archetype-quickstart:pom:RELEASE: Could notfind metadataorg.apache.maven.archetypes:maven-archetype-quickstart/maven-metadata.xml inlocal (E:\maven3\repository)

Failed to resolve version fororg.apache.maven.archetypes:maven-archetype-quickstart:pom:RELEASE: Could notfind metadataorg.apache.maven.archetypes:maven-archetype-quickstart/maven-metadata.xml inlocal (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>

      <!-- United States, 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 for org.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 -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/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即可。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章