如何在 Spring HATEOAS 中反序列化 java.time.LocalDate?

How can I deserialize java.time.LocalDate in Spring HATEOAS?

我正在构建一个 Spring HATEOAS 应用程序。当我 POST 包含 ISO8601 日期的 JSON 文档时,我得到:

Failed to read HTTP message: org.springframework.http.converter.HttpMessageNotReadableException: Could not read document: Text '2016-05-13T21:00:00.000Z' could not be parsed, unparsed text found at index 10 (through reference chain: com.my.package.web.resources.MyResource["startDate"]); nested exception is com.fasterxml.jackson.databind.JsonMappingException: Text '2016-05-13T21:00:00.000Z' could not be parsed, unparsed text found at index 10 (through reference chain: com.my.package.web.resources.MyResource["startDate"])

我按照建议在我的类路径中有 jackson-datatype-jsr310 here。我还尝试使用默认和自定义反序列化器在适当的字段上显式声明 @JsonDeserialize/@JsonSerialize。有什么想法吗?

找到解决方案。原来我的 jackson-dataype-jsr310 有点旧 (2.6.4) 并且日期中的 "Z" 造成了问题。使用最新版本的库 (2.7.3) 解决了这个问题。