標籤:無法建立 tac ons pac getter vax 啟動 eth prope
解決整合jpa時報錯無法建立少匯入entityManagerFactory的問題
最近將IDEA 2018.1版本更新到了2018.2版本,更新好後跑了一下之前的項目,結果就報錯了,這個項目整合了spring data jpa。由於該錯誤有多種原因導致,在解決該錯誤的時候也花了一些時間,所以特別記錄一下。關鍵的報錯資訊如下:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘entityManagerFactory‘ defined in class path resource [org/zero/xunwuproject/config/JpaConfig.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.MappingException: Could not get constructor for org.hibernate.persister.entity.SingleTableEntityPersister
這個錯誤有多種原因導致,在網上查了一下, 大概有以下幾種原因:
實體類的屬性對象沒有設定setter或者getter。
http://stackoverflow.com/questions/18042247/could-not-get-constructor-for-org-hibernate-persister-entity-singletableentitype
沒有匯入javassist的jar檔案 (javassist-3.15.0-GA.jar什麼的)
http://blog.csdn.net/xiaochangwei789/article/details/7712725
- 實體類中的屬性對象名和對應檔的property name不一致。
23127629
而我這裡是第二個原因,缺少javassist的jar包,於是在pom檔案中引入:
<dependency> <groupId>org.javassist</groupId> <artifactId>javassist</artifactId> <version>3.23.1-GA</version></dependency>
引入了這個jar包後,啟動就正常了。
解決整合jpa時報錯無法建立少匯入entityManagerFactory的問題