2019-09-27 10:14:54.266 [60] [ERROR] c.b.c.GlobalExceptionHandler:27 - 系统级异常处理,异常内容:
org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Can not deserialize value of type java.util.Date from String "2019-09-26 17:25:57": not a valid representation (error: Failed to parse Date value '2019-09-26 17:25:57': Can not parse date "2019-09-26 17:25:57": while it seems to fit format 'yyyy-MM-dd'T'HH:mm:ss.SSS', parsing fails (leniency? null)); nested exception is com.fasterxml.jackson.databind.exc.InvalidFormatException: Can not deserialize value of type java.util.Date from String "2019-09-26 17:25:57": not a valid representation (error: Failed to parse Date value '2019-09-26 17:25:57': Can not parse date "2019-09-26 17:25:57": while it seems to fit format 'yyyy-MM-dd'T'HH:mm:ss.SSS', parsing fails (leniency? null))
at [Source: java.io.PushbackInputStream@b26105c; line: 3, column: 19] (through reference chain: com.bmadmin.project.businessproject.domain.SalesSystem.SalesOrderHeadDO["outStorageTime"])
解决方法:
在userDto中的日期格式上增加下面注解就可以解决:
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
如:创建时间字段:
@ApiModelProperty(value = "创建时间 ;不需要传")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createDate;
=============================================================
===》
实体类加注解:
@Temporal(TemporalType.TIMESTAMP)