[英]How to include dependency classes in my eclipse(juno) project?
我將所有jar文件都保留在Web-content/WEB-INF/lib
並內置到Java-Resources/Libraries
。 我的項目在過去的兩周內一直運行良好,但是今天突然所有依賴項都拋出ClassNotFoundException
。 請幫忙。
我還嘗試將所有jar保留在另一個文件夾中,並使用Java Build Path>庫將其添加。
奇怪的是,所有的罐子都添加到了庫中 ,直到昨天一切正常!!
編輯:我在WEB-INF / lib中制作了jar的兩個副本(簡單的復制粘貼),並使用構建路徑再次添加了它們(新副本)(因此,每個實例都有兩個實例)。 這解決了問題。 為什么會這樣呢?
編輯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>
通常,如果要通過其他軟件來管理依賴項,則維護項目要簡單得多。
如果您的參考資料有問題,則應使用MAVEN(MVN)。 然后eclipse將解決所有依賴的JAR並正確配置eclipse。
如果您希望使用Eclipse,請在此處將項目中的.classpath文件粘貼到此處。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.