我是靠谱客的博主 无语人生,最近开发中收集的这篇文章主要介绍JSON parse error: Cannot deserialize value of type `java.util.Date` from String “2022-06-20T12:26:06,觉得挺不错的,现在分享给大家,希望可以做个参考。
概述
在feign调用的过程中(返回一个实体类),遇到了一个错误,关于解析日期格式的:
Caused by: org.springframework.web.client.RestClientException: Error while extracting response for type [class com.cjw.order.entity.UserMemberDTO] and content type [application/json]; nested exception is org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Cannot deserialize value of type `java.util.Date` from String "2022-06-20T12:26:06.000+0000": not a valid representation (error: Failed to parse Date value '2022-06-20T12:26:06.000+0000': Unparseable date: "2022-06-20T12:26:06.000+0000"); nested exception is com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot deserialize value of type `java.util.Date` from String "2022-06-20T12:26:06.000+0000": not a valid representation (error: Failed to parse Date value '2022-06-20T12:26:06.000+0000': Unparseable date: "2022-06-20T12:26:06.000+0000")
at [Source: (PushbackInputStream); line: 1, column: 545] (through reference chain: com.cjw.order.entity.UserMemberDTO["gmtCreate"])
at org.springframework.web.client.HttpMessageConverterExtractor.extractData(HttpMessageConverterExtractor.java:119)
at org.springframework.cloud.openfeign.support.SpringDecoder.decode(SpringDecoder.java:59)
at org.springframework.cloud.openfeign.support.ResponseEntityDecoder.decode(ResponseEntityDecoder.java:62)
at feign.optionals.OptionalDecoder.decode(OptionalDecoder.java:36)
at feign.SynchronousMethodHandler.decode(SynchronousMethodHandler.java:178)
... 60 more
解决办法,加个注解
@JsonFormat(pattern="yyyy-MM-dd")
private Date gmtCreate;
最后
以上就是无语人生为你收集整理的JSON parse error: Cannot deserialize value of type `java.util.Date` from String “2022-06-20T12:26:06的全部内容,希望文章能够帮你解决JSON parse error: Cannot deserialize value of type `java.util.Date` from String “2022-06-20T12:26:06所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复