升級到 Hibernate 5 後,提示有錯誤:java
org.hibernate.engine.spi.SessionFactoryImplementor.getProperties()Ljava/util/Map;
完整的錯誤棧爲:ide
java.lang.NoSuchMethodError: org.hibernate.engine.spi.SessionFactoryImplementor.getProperties()Ljava/util/Map; at org.hibernate.cache.internal.EnabledCaching.<init>(EnabledCaching.java:77) at org.hibernate.engine.spi.CacheInitiator.initiateService(CacheInitiator.java:33) at org.hibernate.engine.spi.CacheInitiator.initiateService(CacheInitiator.java:24) at org.hibernate.service.spi.SessionFactoryServiceInitiator.initiateService(SessionFactoryServiceInitiator.java:30) at org.hibernate.service.internal.SessionFactoryServiceRegistryImpl.initiateService(SessionFactoryServiceRegistryImpl.java:68) at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:263) at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:237) at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:214) at org.hibernate.service.internal.SessionFactoryServiceRegistryImpl.getService(SessionFactoryServiceRegistryImpl.java:109) at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:239) at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:467)
若是你僅僅從錯誤信息,你可能看不出什麼問題。ui
Google 搜索也找不到什麼好的回答。通過咱們對源代碼的分析和排查,咱們發現這是一個 JPA 版本不兼容的問題。hibernate
你的Hibernate 可能須要更高版本的 JPA,可是你的項目中只有低版本的 JPAorm
有關 JPA 的支持列表能夠訪問頁面:https://hibernate.org/orm/releases/blog
請查看 JPA 的版本配置列表。get
根據咱們的項目狀況,咱們須要使用 JPA 2.2,可是咱們沒有在 Maven 中指定 JPA 致使了上面的錯誤。it