2017-08-03 169 views
-3

我想春天4與Hibernate 4集成和我使用的Eclipse IDE用了Maven的依賴關係,但我正在逐漸下面提到的錯誤:春天 - Hibernate集成

產生的原因:java.lang.classnotfoundexception:org.hibernate.annotations實體

如果任何一個已經實現並且工作正常,那麼請你可以分享這個項目以供參考,這樣我就可以理解整合的流程,因爲我對spring和hibernate有所瞭解。我需要一些很好的指導。

+0

該錯誤表示您在類路徑中缺少JAR文件。您需要找到包含org.hibernate.annotations.Entity類的JAR文件,並將其添加到Eclipse中的項目中。這個文件應該在'hibernate-core-4.x.x.Final.jar' – Jesper

+0

但是請注意'org.hibernate.annotations.Entity'已被棄用,您應該使用JPA註釋'javax.persistence.Entity'來代替。 – Jesper

+2

https://stackoverflow.com/questions/7985970/org-hibernate-annotations-entity-deprecated-in-hibernate-4 – soorapadman

回答

-2

你需要使用一些依賴,你可以在下面找到:

<dependency> 
    <groupId>org.hibernate</groupId> 
    <artifactId>hibernate-commons-annotations</artifactId> 
    <version>3.2.0</version> 
</dependency> 

<dependency> 
    <groupId>org.hibernate</groupId> 
    <artifactId>hibernate-annotations</artifactId> 
    <version>3.5.5-Final</version> 
</dependency> 


<dependency> 
    <groupId>org.hibernate</groupId> 
    <artifactId>hibernate-entitymanager</artifactId> 
    <version>5.2.9.Final</version> 
</dependency> 

,如果你不使用Maven項目,那麼你需要下載hibernate-entitymanagerhibernate-annotations罐子,加入到構建路徑和重建項目

+0

Abishek在上面的問題中說,他沒有使用Maven。 – Jesper

+0

然後下載'hibernate-entitymanager'和'hibernate-annotations'的jar,並將jar文件添加到構建路徑中。 – Sharma

+0

這不會回答問題OP說版本4,但你爲什麼建議5? – soorapadman