使用PostMan传递json数据Cannot deserialize value of type `java.util.Date` from String “2020-3-3“: not a val

异常
Resolved [org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Cannot deserialize value of type java.util.Date from String “2020-3-3”: not a valid representation (error: Failed to parse Date value ‘2020-3-3’: Cannot parse date “2020-3-3”: while it seems to fit format ‘yyyy-MM-dd’, parsing fails (leniency? null)); nested exception is com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot deserialize value of type java.util.Date from String “2020-3-3”: not a valid representation (error: Failed to parse Date value ‘2020-3-3’: Cannot parse date “2020-3-3”: while it seems to fit format ‘yyyy-MM-dd’, parsing fails (leniency? null))
at [Source: (PushbackInputStream); line: 2, column: 12] (through reference chain: com.czxy.model.User[“birthday”])]

原因: 实体类上么没有写这个注解
@JsonFormat(pattern =“yyyy-MM-dd”) ,所以出现出错
使用PostMan传递json数据Cannot deserialize value of type `java.util.Date` from String “2020-3-3“: not a val_第1张图片
解决这个措施
在这字段上填写上这个注解@JsonFormat(pattern =“yyyy-MM-dd”) ok了

异常
Cannot deserialize value of type java.util.Date from String “2020-3-3”: not a valid representation (error: Failed to parse Date value ‘2020-3-3’

你可能感兴趣的:(Cannot,deserialize,value,of,type,`j)