1、LocalDateTime的序列化
Redis的jackson不支持LocalDateTime时间类
Request processing failed; nested exception is
org.springframework.data.redis.serializer.SerializationException: Could not write JSON: Java 8
date/time type `java.time.LocalDateTime` not supported by default: add Module
"com.fasterxml.jackson.datatype:jackson-datatype-jsr310" to enable handling (through reference
chain: com.my.seckill.dao.pojo.GoodsVo["startDate"]); nested exception is
com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Java 8 date/time type
`java.time.LocalDateTime` not supported
解决方案:
1)添加依赖
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>2.13.2</version>
</dependency>
2)添加注解
@JsonDeserialize(using = LocalDateTimeDeserializer.class)
@JsonSerialize(using = LocalDateTimeSerializer.class)
private LocalDateTime gmtCreate;
2、缓存在增删改查中的处理逻辑
|