Cannot construct instance of `java.time.LocalDateTime`
时间: 2024-02-24 14:22:10 浏览: 202
回答: "Cannot construct instance of `java.time.LocalDateTime`"错误是由于在将Json字符串赋值给对象时,无法构造`java.time.LocalDateTime`实例引起的。\[1\]\[2\]解决这个问题的方法有两种。一种是通过设置时间格式化来解决,可以添加一个Bean或使用`@JsonFormat`注解来设置时间格式化。\[3\]另一种是通过设置时间的反序列化方式来解决,可以使用`JavaTimeModule`来添加对`LocalDateTime`的序列化器。这样,在将Json字符串转换为对象时,就能正确地构造`java.time.LocalDateTime`实例了。
#### 引用[.reference_title]
- *1* [【异常】LocalDateTime序列化问题:Cannot construct instance of `java.time.LocalDate`](https://blog.csdn.net/REX1024/article/details/123657816)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
- *2* [程序错误:Cannot construct instance of `java.time.LocalDate` LocalDateTime序列化问题:](https://blog.csdn.net/wang121213145/article/details/126750807)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
- *3* [【BUG解决】Cannot construct instance of java.time.LocalDate....Could not read JSON: Expected array.....](https://blog.csdn.net/qq_43751336/article/details/113622309)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文