2014-09-28 93 views
0

我在pom.xml中配置了「hibernate-core-4.3.6.Final.jar」,如下所示。java.lang.NoClassDefFoundError:org/hibernate/criterion/Criterion | Spring Hibernate

 <dependency> 
      <groupId>org.hibernate</groupId> 
      <artifactId>hibernate-core</artifactId> 
      <version>4.3.6.Final</version> 
      <scope>system</scope> 
      <systemPath>G:/Setups/hibernate-release-4.3.6.Final/hibernate-release-4.3.6.Final/lib/required/hibernate-core-4.3.6.Final.jar</systemPath> 
     </dependency> 

當我嘗試在服務層注入hibernate DAO類時,我得到此異常。

+0

而異常的完整堆棧跟蹤是?您是否添加了G:/Setups/hibernate-release-4.3.6.Final/hibernate-release-4.3.6.Final/lib/required下列出的所有其他jar文件?因爲,正如文件夾名稱所示,它們是必需的。另外,你是否理解系統範圍是什麼?閱讀http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#System_Dependencies – 2014-09-28 17:23:06

回答

2

刪除範圍和systemPath部分並重新生成項目。 maven會依賴這些依賴關係。

+0

它工作。我刪除了範圍和systemPath並保存在repo目錄中的jar文件。謝謝。 – Mohit 2014-10-02 01:42:04

+0

你可以選擇它作爲正確答案,以便人們可以從中受益 – 2014-10-02 06:49:10