[英]in java date format: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of `java.time.LocalDate`
In my Java 8 code I'm trying to format string date to LocalDate format.在我的 Java 8 代码中,我试图将字符串日期格式化为 LocalDate 格式。 I am using the LocalDateDeserializer.class.
我正在使用 LocalDateDeserializer.class。 I get the error
我得到错误
com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of `java.time.LocalDate` (no Creators, like default construct, exist): no String-argument constructor/factory method to deserialize from String value ('19440912').
Can any one tell me what could be the error?谁能告诉我可能是什么错误?
You need to add the datetime module from jackson-modules-java8 :您需要从jackson-modules-java8添加datetime 模块:
Datatype module to make Jackson recognize Java 8 Date & Time API data types (JSR-310).
数据类型模块使 Jackson 识别 Java 8 日期和时间 API 数据类型 (JSR-310)。
Register it using:注册它使用:
ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(new JavaTimeModule());
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.