joda.time.DateTime.toLocalDateTime() NoSuchMethodError

joda.time.DateTime.toLocalDateTime() NoSuchMethodError

我正在尝试在我的 Spring 引导配置中将 Joda LocalDateTime 与 JPA 结合使用。 为此,我阅读了 this 教程,并且可以毫无问题地使用 DateTime。 当我尝试使用 LocalDateTime 时,问题就来了。出于某种原因,从我的数据库中获取实体时,抛出错误:

java.lang.NoSuchMethodError: org.joda.time.DateTime.toLocalDateTime()Lorg/joda/time/LocalDateTime;

我已经检查过 toLocalDateTime 方法确实存在于 Joda Time 中:

那么,到底是什么? D:

我也尝试按照教程的建议设置 @Type 显式,但得到了相同的结果:

@Column(name = "myLocalDateTime")
@Type(type = "org.jadira.usertype.dateandtime.joda.PersistentLocalDateTime")
private LocalDateTime localDateTime;

要从我的数据库中检索数据,我只是使用 spring-data 存储库。

以下是关于我的环境的一些信息:

Gradle 依赖关系:

// ...
compile 'org.hibernate:hibernate-core:5.1.16.Final'
compile 'org.hibernate:hibernate-validator:5.2.3.Final'
compile 'org.hibernate:hibernate-entitymanager:5.1.0.Final'
compile 'joda-time:joda-time'
compile group: 'org.jadira.usertype', name: 'usertype.core', version: '5.0.0.GA'

application.properties:

# ...
spring.jpa.properties.jadira.usertype.autoRegisterUserTypes = true

我 运行 在 Java 7 上 Spring 开机 1.5.15.RELEASE

非常感谢任何帮助。

编辑

有趣的是,在我的数据库中保存一个带有 LocalDateTime 字段的记录工作得很好...:/

这是我项目中的库列表:

Gradle: antlr:antlr:2.7.7
Gradle: aopalliance:aopalliance:1.0
Gradle: ch.qos.logback:logback-classic:1.1.11
Gradle: ch.qos.logback:logback-core:1.1.11
Gradle: com.fasterxml.jackson.core:jackson-annotations:2.8.0
Gradle: com.fasterxml.jackson.core:jackson-core:2.8.11
Gradle: com.fasterxml.jackson.core:jackson-databind:2.8.11.2
Gradle: com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.8.11
Gradle: com.fasterxml.jackson.module:jackson-module-jaxb-annotations:2.8.11
Gradle: com.fasterxml.woodstox:woodstox-core:5.0.3
Gradle: com.fasterxml:classmate:1.3.4
Gradle: com.github.virtuald:curvesapi:1.04
Gradle: com.google.code.findbugs:jsr305:1.3.9
Gradle: com.google.guava:guava:19.0
Gradle: com.infradna.tool:bridge-method-annotation:1.13
Gradle: com.jayway.jsonpath:json-path:2.2.0
Gradle: com.mysema.commons:mysema-commons-lang:0.2.4
Gradle: com.querydsl:querydsl-core:4.1.4
Gradle: com.querydsl:querydsl-jpa:4.1.4
Gradle: com.sun.istack:istack-commons-runtime:2.16
Gradle: com.sun.xml.bind:jaxb-core:2.2.7
Gradle: com.sun.xml.bind:jaxb-impl:2.2.7
Gradle: com.sun.xml.fastinfoset:FastInfoset:1.2.12
Gradle: com.vaadin.external.google:android-json:0.0.20131108.vaadin1
Gradle: commons-beanutils:commons-beanutils:1.9.3
Gradle: commons-codec:commons-codec:1.10
Gradle: commons-collections:commons-collections:3.2.2
Gradle: dom4j:dom4j:1.6.1
Gradle: io.netty:netty-all:4.1.5.Final
Gradle: javax.inject:javax.inject:1
Gradle: javax.servlet:javax.servlet-api:3.1.0
Gradle: javax.transaction:javax.transaction-api:1.2
Gradle: javax.validation:validation-api:1.1.0.Final
Gradle: javax.xml.bind:jaxb-api:2.2.7
Gradle: javax.xml.bind:jsr173_api:1.0
Gradle: javax.xml.stream:stax-api:1.0-2
Gradle: joda-time:joda-time:2.9.9
Gradle: junit:junit:4.12
Gradle: net.minidev:accessors-smart:1.1
Gradle: net.minidev:json-smart:2.2.1
Gradle: org.apache.activemq:artemis-commons:1.5.6
Gradle: org.apache.activemq:artemis-core-client:1.5.6
Gradle: org.apache.activemq:artemis-jms-client:1.5.6
Gradle: org.apache.activemq:artemis-selector:1.5.6
Gradle: org.apache.commons:commons-collections4:4.1
Gradle: org.apache.commons:commons-lang3:3.4
Gradle: org.apache.geronimo.specs:geronimo-jms_2.0_spec:1.0-alpha-2
Gradle: org.apache.geronimo.specs:geronimo-json_1.0_spec:1.0-alpha-1
Gradle: org.apache.geronimo.specs:geronimo-jta_1.1_spec:1.1.1
Gradle: org.apache.johnzon:johnzon-core:0.9.5
Gradle: org.apache.poi:poi-ooxml-schemas:3.17
Gradle: org.apache.poi:poi-ooxml:3.17
Gradle: org.apache.poi:poi:3.17
Gradle: org.apache.santuario:xmlsec:2.0.7
Gradle: org.apache.xmlbeans:xmlbeans:2.6.0
Gradle: org.aspectj:aspectjweaver:1.8.13
Gradle: org.assertj:assertj-core:2.6.0
Gradle: org.atteo:evo-inflector:1.2.2
Gradle: org.codehaus.woodstox:stax2-api:3.1.4
Gradle: org.codehaus.woodstox:woodstox-core-asl:4.4.1
Gradle: org.hamcrest:hamcrest-core:1.3
Gradle: org.hamcrest:hamcrest-library:1.3
Gradle: org.hibernate.common:hibernate-commons-annotations:5.0.1.Final
Gradle: org.hibernate.javax.persistence:hibernate-jpa-2.1-api:1.0.0.Final
Gradle: org.hibernate:hibernate-core:5.1.16.Final
Gradle: org.hibernate:hibernate-entitymanager:5.1.0.Final
Gradle: org.hibernate:hibernate-validator:5.2.3.Final
Gradle: org.jadira.usertype:usertype.core:5.0.0.GA
Gradle: org.jadira.usertype:usertype.spi:5.0.0.GA
Gradle: org.javassist:javassist:3.21.0-GA
Gradle: org.jboss.logging:jboss-logging:3.3.2.Final
Gradle: org.jboss:jandex:2.0.3.Final
Gradle: org.jetbrains.kotlin:kotlin-stdlib-common:1.2.70
Gradle: org.jetbrains.kotlin:kotlin-stdlib:1.2.70
Gradle: org.jetbrains:annotations:13.0
Gradle: org.jgroups:jgroups:3.6.9.Final
Gradle: org.mockito:mockito-core:1.10.19
Gradle: org.objenesis:objenesis:2.1
Gradle: org.ow2.asm:asm:5.0.3
Gradle: org.skyscreamer:jsonassert:1.4.0
Gradle: org.slf4j:jcl-over-slf4j:1.7.25
Gradle: org.slf4j:jul-to-slf4j:1.7.25
Gradle: org.slf4j:log4j-over-slf4j:1.7.25
Gradle: org.slf4j:slf4j-api:1.7.25
Gradle: org.springframework.boot:spring-boot-autoconfigure:1.5.15.RELEASE
Gradle: org.springframework.boot:spring-boot-devtools:1.5.15.RELEASE
Gradle: org.springframework.boot:spring-boot-starter-aop:1.5.15.RELEASE
Gradle: org.springframework.boot:spring-boot-starter-artemis:1.5.15.RELEASE
Gradle: org.springframework.boot:spring-boot-starter-data-jpa:1.5.15.RELEASE
Gradle: org.springframework.boot:spring-boot-starter-data-rest:1.5.15.RELEASE
Gradle: org.springframework.boot:spring-boot-starter-jdbc:1.5.15.RELEASE
Gradle: org.springframework.boot:spring-boot-starter-logging:1.5.15.RELEASE
Gradle: org.springframework.boot:spring-boot-starter-security:1.5.15.RELEASE
Gradle: org.springframework.boot:spring-boot-starter-test:1.5.15.RELEASE
Gradle: org.springframework.boot:spring-boot-starter-web-services:1.5.15.RELEASE
Gradle: org.springframework.boot:spring-boot-starter-web:1.5.15.RELEASE
Gradle: org.springframework.boot:spring-boot-starter:1.5.15.RELEASE
Gradle: org.springframework.boot:spring-boot-test-autoconfigure:1.5.15.RELEASE
Gradle: org.springframework.boot:spring-boot-test:1.5.15.RELEASE
Gradle: org.springframework.boot:spring-boot:1.5.15.RELEASE
Gradle: org.springframework.data:spring-data-commons:1.13.14.RELEASE
Gradle: org.springframework.data:spring-data-jpa:1.11.14.RELEASE
Gradle: org.springframework.data:spring-data-rest-core:2.6.14.RELEASE
Gradle: org.springframework.data:spring-data-rest-webmvc:2.6.14.RELEASE
Gradle: org.springframework.hateoas:spring-hateoas:0.23.0.RELEASE
Gradle: org.springframework.plugin:spring-plugin-core:1.2.0.RELEASE
Gradle: org.springframework.security:spring-security-config:4.2.7.RELEASE
Gradle: org.springframework.security:spring-security-core:4.2.7.RELEASE
Gradle: org.springframework.security:spring-security-test:4.2.7.RELEASE
Gradle: org.springframework.security:spring-security-web:4.2.7.RELEASE
Gradle: org.springframework.ws:spring-ws-core:2.4.2.RELEASE
Gradle: org.springframework.ws:spring-xml:2.4.2.RELEASE
Gradle: org.springframework:spring-aop:4.3.18.RELEASE
Gradle: org.springframework:spring-aspects:4.3.18.RELEASE
Gradle: org.springframework:spring-beans:4.3.18.RELEASE
Gradle: org.springframework:spring-context:4.3.18.RELEASE
Gradle: org.springframework:spring-core:4.3.18.RELEASE
Gradle: org.springframework:spring-expression:4.3.18.RELEASE
Gradle: org.springframework:spring-jdbc:4.3.18.RELEASE
Gradle: org.springframework:spring-jms:4.3.18.RELEASE
Gradle: org.springframework:spring-messaging:4.3.18.RELEASE
Gradle: org.springframework:spring-orm:4.3.18.RELEASE
Gradle: org.springframework:spring-oxm:4.3.18.RELEASE
Gradle: org.springframework:spring-test:4.3.18.RELEASE
Gradle: org.springframework:spring-tx:4.3.18.RELEASE
Gradle: org.springframework:spring-web:4.3.18.RELEASE
Gradle: org.springframework:spring-webmvc:4.3.18.RELEASE
Gradle: org.yaml:snakeyaml:1.17
Gradle: stax:stax-api:1.0.1

已使用 中描述的解决方案解决了问题。

正如答案所说,WebLogic 在类路径中包含它自己的 joda.time 并使用它,除非我明确告诉它不要这样做。