2015-10-06 206 views
1

我已將所有jar文件保存在Web-content/WEB-INF/lib之內,並且構建成Java-Resources/Libraries。我的項目在過去的兩週內一直很順利,但是今天突然所有的依賴投擲了ClassNotFoundException。請幫忙。如何在我的eclipse(juno)項目中包含依賴類?

我也嘗試保持所有的jar在另一個文件夾中,並使用Java添加它們Build Path> libraries

奇怪的是,所有的罐子都加在圖書館和一切工作正常,直到昨天!

編輯:我在WEB-INF/lib(簡單的複製粘貼)中製作了兩個jar副本,並使用Build Path重新添加它們(新副本)(所以現在每個都有兩個實例)。這解決了這個問題。 任何意見爲什麼發生這種情況?

編輯2:我的類路徑文件:

<?xml version="1.0" encoding="UTF-8"?> 
<classpath> 
    <classpathentry kind="src" path="src"/> 
    <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk1.7.0_45"> 
     <attributes> 
      <attribute name="owner.project.facets" value="java"/> 
     </attributes> 
    </classpathentry> 
    <classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/Apache Tomcat v7.0"> 
     <attributes> 
      <attribute name="owner.project.facets" value="jst.web"/> 
     </attributes> 
    </classpathentry> 
    <classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/> 
    <classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/> 

    <classpathentry kind="lib" path="WebContent/WEB-INF/lib/jstl-1.2.jar"/> 

    <classpathentry kind="lib" path="WebContent/WEB-INF/lib/commons-codec-1.9.jar"/> 
    <classpathentry kind="lib" path="WebContent/WEB-INF/lib/poi-ooxml-3.13-20150929.jar"/> 
    <classpathentry kind="lib" path="WebContent/WEB-INF/lib/poi-ooxml-schemas-3.13-20150929.jar"/> 
    <classpathentry kind="lib" path="WebContent/WEB-INF/lib/xmlbeans-2.6.0.jar"/> 
    <classpathentry kind="lib" path="WebContent/WEB-INF/lib/commons-logging-1.1.3.jar"/> 
    <classpathentry kind="lib" path="WebContent/WEB-INF/lib/junit-4.12.jar"/> 
    <classpathentry kind="lib" path="WebContent/WEB-INF/lib/log4j-1.2.17.jar"/> 
    <classpathentry kind="lib" path="WebContent/WEB-INF/lib/poi-excelant-3.13-20150929.jar"/> 
    <classpathentry kind="lib" path="WebContent/WEB-INF/lib/poi-scratchpad-3.13-20150929.jar"/> 
    <classpathentry kind="lib" path="WebContent/WEB-INF/lib/commons-fileupload-1.3.1.jar"/> 
    <classpathentry kind="lib" path="WebContent/WEB-INF/lib/commons-io-2.4.jar"/> 
    <classpathentry kind="lib" path="WebContent/dependecies/commons-codec-1.9.jar"/> 
    <classpathentry kind="lib" path="WebContent/dependecies/commons-fileupload-1.3.1.jar"/> 
    <classpathentry kind="lib" path="WebContent/dependecies/commons-io-2.4.jar"/> 
    <classpathentry kind="lib" path="WebContent/dependecies/commons-logging-1.1.3.jar"/> 
    <classpathentry kind="lib" path="WebContent/dependecies/jstl-1.2.jar"/> 
    <classpathentry kind="lib" path="WebContent/dependecies/junit-4.12.jar"/> 
    <classpathentry kind="lib" path="WebContent/dependecies/log4j-1.2.17.jar"/> 
    <classpathentry kind="lib" path="WebContent/dependecies/poi-excelant-3.13-20150929.jar"/> 
    <classpathentry kind="lib" path="WebContent/dependecies/poi-ooxml-3.13-20150929.jar"/> 
    <classpathentry kind="lib" path="WebContent/dependecies/poi-ooxml-schemas-3.13-20150929.jar"/> 
    <classpathentry kind="lib" path="WebContent/dependecies/poi-scratchpad-3.13-20150929.jar"/> 
    <classpathentry kind="lib" path="WebContent/dependecies/xmlbeans-2.6.0.jar"/> 
    <classpathentry kind="lib" path="WebContent/WEB-INF/lib/mysql-connector-java.jar"/> 
    <classpathentry kind="lib" path="WebContent/WEB-INF/lib/mysql-connector-java-5.1.13-bin.jar"/> 
    <classpathentry kind="lib" path="WebContent/WEB-INF/lib/Copy of jstl-1.2.jar"/> 
    <classpathentry kind="lib" path="WebContent/WEB-INF/lib/poi-3.13-20150929.jar"/> 
    <classpathentry kind="lib" path="WebContent/WEB-INF/lib/Copy of poi-3.13-20150929.jar"/> 
    <classpathentry kind="output" path="build/classes"/> 
</classpath> 

回答

0

總體保持你的項目它的(的JAR文件的多個副本和「依賴」文件夾中,當我嘗試不同的東西來解決我的問題創建)如果您使用其他軟件來管理您的依賴關係,則更簡單得多。

如果您遇到問題,請使用MAVEN(MVN)。然後eclipse將解析所有依賴JAR並正確配置您的eclipse。

如果您想留在Eclipse中,請在此處粘貼您的項目中的.classpath文件。

+0

請檢查編輯 – user2473779

+0

它看起來不錯,您是否嘗試刪除所有庫,然後再添加一次? – KirkoR

+0

製作以前的庫的副本,並再次添加他們爲我工作,所以更換以前的庫也將工作得很好!但是爲什麼突然發生這種想法?這是否意味着日食(不使用MAVEN)不穩定? – user2473779

相關問題