Jackson序列化与反序列化LocalDateTime、TimeStamp 等时间类型参数报错

您所在的位置:网站首页 Jackson解析@报错 Jackson序列化与反序列化LocalDateTime、TimeStamp 等时间类型参数报错

Jackson序列化与反序列化LocalDateTime、TimeStamp 等时间类型参数报错

2023-10-27 18:16| 来源: 网络整理| 查看: 265

场景: 实体类Entity 部分属性:

/** * 创建时间 */ @Column(name = "gmt_create") protected Timestamp gmtCreate; /** * 修改时间 */ @Column(name = "gmt_modified") protected Timestamp gmtModified;

controller层采用实体类接收参数:

@PostMapping("/testFeign") public void testFeign(@RequestBody JourneyEntity journeyEntity) { //业务代码 }

Postman 发起post请求: 参数如下: { “journeyId”:“fd96adc11d6d4e11a0c184297dbedc98”, “name”:“测试版本下线”, “version”:“3”, “maxVersion”:“4”, “audience”:“CROWD”, “type”:“service”, “gmtCreate”:“2020-05-27 10:59:40”,–字符串类型参数 “conflictResolution”:“concurrent”, “layoutContent”:“hhhhh”, “policyDelivery”:"{‘type’:‘IMMEDIATELY’}" }

结果报错如下:

Caused by: com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot deserialize value of type `java.sql.Timestamp` from String "2020-05-27 10:59:40": not a valid representation (error: Failed to parse Date value '2020-05-27 10:59:40': Cannot parse date "2020-05-27 10:59:40": while it seems to fit format 'yyyy-MM-dd'T'HH:mm:ss.SSSZ', parsing fails (leniency? null)) at [Source: (PushbackInputStream); line: 8, column: 14] (through reference chain: com.aliyun.opaas.


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3