且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

无法从START_OBJECT令牌反序列化org.joda.time.DateTime或LocalDate的实例

更新时间:2022-06-11 17:22:56

为了解决类似的问题,我做了以下工作,

To solve a similar problem I did the following,

我从http://mvnrepository.com/artifact/com.fasterxml.jackson.datatype/jackson-datatype -joda / 2.2.1 如果您正在使用maven,依赖项定义也在那里。

I downloaded jackson-datatype-joda-2.2.1.jar from http://mvnrepository.com/artifact/com.fasterxml.jackson.datatype/jackson-datatype-joda/2.2.1 if you are using maven the dependency definition is there too.

然后我为我的应用中的每个LocalDate字段添加了一个注释如下:

then I added an annotation for every LocalDate field in my app as follows:

@JsonDeserialize(using=LocalDateDeserializer.class)
private LocalDate releasedDate;

导入如下所示:

import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.datatype.joda.deser.LocalDateDeserializer;

问题消失了。

希望这有帮助!