在接口传入含有LocalTime类型属性对象的时候,反序列化失败报错:
message:JSON parse error: Can not deserialize value of type java.time.LocalDateTime from String “2019-12-12 11:25:07”: Text ‘2019-12-12 11:25:07’ could not be parsed at index 10; nested exception is com.fasterxml.jackson.databind.exc.
原来是要对时间的格式做一些说明:
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime appointmentTime;
或者使用LocalDateTime的序列化反序列化方法:
@JsonDeserialize(using = LocalDateTimeDeserializer.class)
@JsonSerialize(using = LocalDateTimeSerializer.class)
private LocalDateTime createTime;