场景是:
- Gradle 项目
@JsonProperty
,无法将 String 反序列化为LocalDateTime
- 找到这个:http://andreitsibets.blogspot.com.br/2014/04/java8-localdate-jackson-json.html
- 当然是将它从 Maven 移植到 Grade
- 我正在尝试使用
@JsonDeserialize(using=LocalDateTimeDeserializer.class)
问题:我无法将 LocalDateTimeDeserializer
导入到我的代码中
这是我的 gradle 依赖项部分:
dependencies {
compile ("org.springframework.social:spring-social-core:$springSocialVersion")
compile ("org.springframework.social:spring-social-config:$springSocialVersion")
compile ("org.springframework.social:spring-social-security:$springSocialVersion", optional)
compile ("com.fasterxml.jackson.core:jackson-core:$jacksonVersion")
compile ("com.fasterxml.jackson.core:jackson-databind:$jacksonVersion")
compile ("com.fasterxml.jackson.core:jackson-annotations:$jacksonVersion")
compile ("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jsr310Version")
compile ("org.springframework.security:spring-security-crypto:$springSecurityCryptoVersion")
compile ("javax.servlet:javax.servlet-api:$servletApiVersion", provided)
testCompile ("org.springframework:spring-test:$springVersion")
}
我确信这是一个陷阱!它在哪里?
非常感谢您的帮助!
最佳答案
好的,解决了!
问题(显然)与类路径有关。 我是 Eclipse 开发的新手,所以我对它的工作原理每天都越来越清楚。
要解决类似问题,请执行以下操作:
将依赖项添加到您的 gradle 构建中
编译(“com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.5.1”)
您必须刷新类路径。使用 gradle,为此,运行
gradle cleanEclipse && gradle eclipse
刷新您的 eclipse 。在我的身上,我真的不得不重新启动它。
在此之后,它发挥了神奇作用:LocalDateTimeDeserializer
在那里供我导入。
注意:我不喜欢我自己的方法,并且我认为它太古怪而不正确,所以我会留下这个问题以防万一对这里发生的事情有更清楚的了解会得到更好的答案。
应该为那些像我一样继续前进的人提供引用。
关于java - Gradle 依赖声明(JSR310),但 LocalDateTimeDeserializer 不可导入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29448020/