【发布时间】:2017-06-12 07:51:37
【问题描述】:
我有一些带有 Joda DateTime 字段的实体。 尝试启动应用程序时,出现以下错误:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: org.hibernate.engine.spi.SessionFactoryImplementor.getProperties()Ljava/util/Map;
[...]
Caused by: java.lang.NoSuchMethodError: org.hibernate.engine.spi.SessionFactoryImplementor.getProperties()Ljava/util/Map;
at org.jadira.usertype.spi.shared.AbstractUserTypeHibernateIntegrator.integrate(AbstractUserTypeHibernateIntegrator.java:192) ~[usertype.spi-6.0.1.GA.jar:na]
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:280) ~[hibernate-core-5.0.11.Final.jar:5.0.11.Final]
at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:444) ~[hibernate-core-5.0.11.Final.jar:5.0.11.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:879) ~[hibernate-entitymanager-5.0.11.Final.jar:5.0.11.Final]
我试着放了
spring.jpa.properties.jadira.usertype.autoRegisterUserTypes=true
在 application.properties 中,但它不起作用。所以我将 Hibernate 注释添加到我的实体类中:
@Type(type="org.jadira.usertype.dateandtime.joda.PersistentDateTime")
private DateTime from;
它没有用。
我的 pom.xml(部分):
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
</dependency>
<dependency>
<groupId>org.jadira.usertype</groupId>
<artifactId>usertype.core</artifactId>
<version>6.0.1.GA</version>
</dependency>
<!-- Jackson json data bind -->
<dependency>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-json-provider</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-joda</artifactId>
</dependency>
我还尝试了 Jadira usertype.core 6.0.0.GA、5.0.0.GA 和 4.0.0.GA,但没有任何变化。我该如何解决?
=====================编辑
调试使我进入AbstractUserTypeHibernateIntegrator类的第192行
String isEnabled = (String)sessionFactory.getProperties().get("jadira.usertype.autoRegisterUserTypes");
我的调试器说分配给isEnabled 的值是“真”。但是,执行跳转到 finally 子句:ConfigurationHelper.setCurrentSessionFactory((SessionFactory)null)
【问题讨论】:
标签: spring hibernate spring-boot spring-data-jpa jodatime