不能反序列化了,Cannot deserialize value of type `java.util.Date` from String "2018-08-08 10:00:00"

Blade 未结 1 943
305686839
305686839 剑圣 2021-12-15 12:31

一、该问题的重现步骤是什么?

1. 不能反序列化了,Cannot deserialize value of type `java.util.Date` from String "2018-08-08 10:00:00" 


nacos上blade.yaml 也配置了如下设置,但是所有feign调用时日期都不能反序列化。


#jackson配置

jackson:

#null自动转空值

null-to-empty: true

#大数字自动转字符串

big-num-to-string: true

#支持text文本请求,与报文加密同时开启

support-text-plain: false

date-format: yyyy-MM-dd HH:mm:ss


二、你期待的结果是什么?实际看到的又是什么?


三、你正在使用的是什么产品,什么版本?在什么操作系统上?


四、请提供详细的错误堆栈信息,这很重要。

 BladeFeignFallback:[org.springblade.system.user.feign.IUserClient.userInfoById] serviceId:[blade-user] message:[Error while extracting response for type [org.springblade.core.tool.api.R<org.springblade.system.user.entity.User>] and content type [application/json;charset=UTF-8]; nested exception is org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Cannot deserialize value of type `java.util.Date` from String "2018-08-08 10:00:00": not a valid representation (error: Failed to parse Date value '2018-08-08 10:00:00': Cannot parse date "2018-08-08 10:00:00": while it seems to fit format 'yyyy-MM-dd'T'HH:mm:ss.SSSX', parsing fails (leniency? null)); nested exception is com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot deserialize value of type `java.util.Date` from String "2018-08-08 10:00:00": not a valid representation (error: Failed to parse Date value '2018-08-08 10:00:00': Cannot parse date "2018-08-08 10:00:00": while it seems to fit format 'yyyy-MM-dd'T'HH:mm:ss.SSSX', parsing fails (leniency? null))

 at [Source: (PushbackInputStream); line: 1, column: 560] (through reference chain: org.springblade.core.tool.api.R["data"]->org.springblade.system.user.entity.User["birthday"])]

五、若有更多详细信息,请在下面提供。

1条回答
  • 2021-12-15 16:23

    feign传递日期字符串,然后feign实现类进行类型转换。这样做的好处是不用对feign做额外对配置,并且减少了传输损耗。如果一定要feign传递Date,可以百度搜索一下:feign传递Date类型

    0 讨论(0)
提交回复