在SSM中,向Redis中存入信息后,在取出的時候出現
org.springframework.data.redis.serializer.SerializationException:
Could not read JSON: Cannot construct instance of java.time.LocalDateTime (no Creators, like default construct,exist):
no String-argument constructor/factory method to deserialize from String value (‘2019-11-13 18:05:32’)
錯誤,是因為序列化時失敗,在失敗的字段,也就是實體類中時間屬性,添加上以下注解
@JsonDeserialize(using = LocalDateTimeDeserializer.class)
@JsonSerialize(using = LocalDateTimeSerializer.class)