2015-10-06 67 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

相关问题