情景是:
@JsonProperty
,无法将字符串反序列化为 LocalDateTime
@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")
}
我确定这是一个问题!在哪里?
非常感谢您的帮助!
答案 0 :(得分:2)
好的,解决了!
问题(显然)与班级路径有关。 我是Eclipse开发的新手,所以它每天都让我更清晰,更清晰。
要解决类似问题,请执行以下操作:
将依赖项添加到gradle构建中
的 compile ("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.5.1")
强>
您必须刷新类路径。使用gradle,要运行 gradle cleanEclipse && gradle eclipse
刷新你的日食。在我的,我真的不得不重新开始。
在此之后,它发挥了魔力: LocalDateTimeDeserializer
供我导入。
注意:我不喜欢我自己的方法和我认为它太过于胡思乱想,所以我会把这个问题留在任何对这里发生的事情有更清楚了解的人都会得到更好的答案。
应该作为那些撞击头的参考,就像我要继续前进一样。
答案 1 :(得分:1)
如果您无法从项目中的依赖项导入类,那么eclipse可能无法看到gradle-managed依赖项。
为了更好地集成基于gradle的项目,请使用Eclipse Integration Gradle
插件(https://github.com/spring-projects/eclipse-integration-gradle,查看README.md以获取安装说明。)
To"转换"一个项目到gradle项目:
Gradle Project
现在更新您的项目依赖项,右键单击项目目录并运行Gradle
- > Refresh Dependencies