org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Cannot deserialize value of type java.time.LocalDateTime
from String “2022-01-28 03:47:02”: Failed to deserialize java.time.LocalDateTime: (java.time.format.DateTimeParseException) Text ‘2022-01-28 03:47:02’ could not be parsed: Unable to obtain LocalDateTime from TemporalAccessor: {HourOfAmPm=3, MicroOfSecond=0, SecondOfMinute=2, NanoOfSecond=0, MilliOfSecond=0, MinuteOfHour=47},ISO,Asia/Shanghai resolved to 2022-01-28 of type java.time.format.Parsed; nested exception is com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot deserialize value of type java.time.LocalDateTime
from String “2022-01-28 03:47:02”: Failed to deserialize java.time.LocalDateTime: (java.time.format.DateTimeParseException) Text ‘2022-01-28 03:47:02’ could not be parsed: Unable to obtain LocalDateTime from TemporalAccessor: {HourOfAmPm=3, MicroOfSecond=0, SecondOfMinute=2, NanoOfSecond=0, MilliOfSecond=0, MinuteOfHour=47},ISO,Asia/Shanghai resolved to 2022-01-28 of type java.time.format.Parsed
思考
这是前端发送的日期String无法被后端解析为LocalDateTime
如果使用了Timestamp类型来接口,有可能会报下面的异常:
JSON parse error: Can not deserialize value of type java.sql.Timestamp from String
格式没问题,前端传了后端解析不了,去domain层看看bean的问题
解决
shape = JsonFormat.Shape.STRING