报错详细信息
JSON parse error: Cannot deserialize value of type `java.time.LocalDateTime` from String "2021-09-30 16:05:15": Failed to deserialize java.time.LocalDateTime: (java.time.format.DateTimeParseException) Text '2021-09-30 16:05:15' could not be parsed at index 10; nested exception is com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot deserialize value of type `java.time.LocalDateTime` from String "2021-09-30 16:05:15": Failed to deserialize java.time.LocalDateTime: (java.time.format.DateTimeParseException) Text '2021-09-30 16:05:15' could not be parsed at index 10
at [Source: (org.springframework.util.StreamUtils$NonClosingInputStream); line: 6, column: 13] (through reference chain: cn.haiwang.mybatis_test.generator.domain.DtsArticle["addTime"])
解决办法
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private LocalDateTime addTime;
原因分析,注意看中间有个T,所以
报错原因,没有指定pattern,默认使用所以会使用默认的格式,也就是:DateTimeFormatter.ISO_LOCAL_DATE_TIME
,就是类似这样的:2011-12-03T10:15:30