作者:tusdasa

时间:2020-02-19

分类:Java

Spring Cloud

在开发时,我们经常要设置日期格式,使用Spring Cloud过程中,我发现了一个小问题(也可是我菜)。数据在转化未JSON时。时常会从新设计日期的格式如

jackson:
date-format: yyyy-MM-dd HH:mm:ss
time-zone: GMT+8

使用以上方式配置json的时间格式

而在FeignClient 调用微服务时,可能会应出现以下异常

nested exception is org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Cannot deserialize value of type `java.util.Date` from String \"2020-02-01 16:55:03\": not a valid representation (error: Failed to parse Date value '2020-02-01 16:55:03': Cannot parse date \"2020-02-01 16:55:03\": while it seems to fit format 'yyyy-MM-dd'T'HH:mm:ss.SSSZ', parsing fails (leniency? null)); nested exception is com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot deserialize value of type `java.util.Date` from String \"2020-02-01 16:55:03\": not a valid representation (error: Failed to parse Date value '2020-02-01 16:55:03': Cannot parse date \"2020-02-01 16:55:03\": while it seems to fit format 'yyyy-MM-dd'T'HH:mm:ss.SSSZ', parsing fails (leniency? null))\n at [Source: (PushbackInputStream); line: 1, column: 261] (through reference chain: net.tusdasa.evaluation.commons.CommonResponse[\"data\"]->net.tusdasa.evaluation.entity.Term

去掉以上配置,就可以了

©2020编程学习  陕ICP备14012662号-2