|
|
|
@ -36,9 +36,14 @@ public class RedisConfig extends CachingConfigurerSupport |
|
|
|
|
mapper.activateDefaultTyping(LaissezFaireSubTypeValidator.instance, ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.PROPERTY); |
|
|
|
|
serializer.setObjectMapper(mapper); |
|
|
|
|
|
|
|
|
|
template.setValueSerializer(serializer); |
|
|
|
|
// 使用StringRedisSerializer来序列化和反序列化redis的key值
|
|
|
|
|
template.setKeySerializer(new StringRedisSerializer()); |
|
|
|
|
template.setValueSerializer(serializer); |
|
|
|
|
|
|
|
|
|
// Hash的key也采用StringRedisSerializer的序列化方式
|
|
|
|
|
template.setHashKeySerializer(new StringRedisSerializer()); |
|
|
|
|
template.setHashValueSerializer(serializer); |
|
|
|
|
|
|
|
|
|
template.afterPropertiesSet(); |
|
|
|
|
return template; |
|
|
|
|
} |
|
|
|
|