小工具知识网

当前位置: 首页 > 行业知识 > 【报错】Cannot deserialize value of type `java.time.LocalDateTime` from String

行业知识

【报错】Cannot deserialize value of type `java.time.LocalDateTime` from String

2026-12-05 09:40:43 来源:互联网转载

错误描述

接口测试中报错

Cannot deserialize value of type `java.time.LocalDateTime` from String \"2023-10-10 17:23:35\"

原因

这个错误是因为无法将字符串"2023-10-10 17:23:35"反序列化为java.time.LocalDateTime类型的对象。在Java中,LocalDateTime类不支持直接从字符串进行反序列化的index.php/tags-10.html" >操作。

解决办法

在实体类的LocalDateTime 类型的字段上加@JsonFormat注解即可

@JsonFormat(shape = JsonFormat.Shape.STRING, pattern="yyyy-MM-dd HH:mm:ss")

上一篇:伪装IP背后的法律风险,警惕犯罪红线,切勿触碰!

下一篇:无线网服务器怎么安装?