如何在我的eclipse(juno)项目中包含依赖类?

时间:2015-10-06 06:59:58

标签: java eclipse servlets

我已将所有jar文件保存在Web-content/WEB-INF/lib内并构建到Java-Resources/Libraries。我的项目在过去两周一直运行良好,但是,今天突然间所有依赖项都在抛出ClassNotFoundException。请帮忙。

我还尝试将所有jar放在另一个文件夹中,然后使用Java Build Path>添加它们。库

奇怪的是,所有的罐子都添加在下,一切正常,直到昨天!!

编辑:我在WEB-INF / lib(简单复制粘贴)中制作了两个jar副本,并使用Build Path再次添加它们(新副本)(所以,现在每个都有两个实例)。这解决了这个问题。 有关为何发生这种情况的任何观点?

编辑2:我的类路径文件:(当我尝试不同的东西来解决我的问题时,创建了jar文件的多个副本和'dependency'文件夹)

<?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>

1 个答案:

答案 0 :(得分:0)

一般来说,如果您通过其他软件管理依赖项,维护项目会更加简单。

如果您的参考文献出现问题,您应该使用MAVEN(MVN)。然后eclipse将解析所有依赖的JAR并正确配置你的日食。

如果您想继续使用Eclipse,请在此处粘贴您项目中的.classpath文件。