有办法打开 @CachePut 的调试日志吗
@Bean
public RedisTemplate<String, Object> redisTemplate(LettuceConnectionFactory lettuceConnectionFactory) {
// 设置序列化
Jackson2JsonRedisSerializer<Object> jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer<Object>(Object.class);
ObjectMapper om = new ObjectMapper();
om.setVisibility(PropertyAccessor.ALL, Visibility.ANY);
om.enableDefaultTyping(DefaultTyping.NON_FINAL);
jackson2JsonRedisSerializer.setObjectMapper(om);
RedisTemplate<String, Object> redisTemplate = new RedisTemplate<String, Object>();
redisTemplate.setConnectionFactory(lettuceConnectionFactory);
RedisSerializer<?> stringSerializer = new StringRedisSerializer();
redisTemplate.setKeySerializer(stringSerializer);// key 序列化
redisTemplate.setValueSerializer(jackson2JsonRedisSerializer);// value 序列化
redisTemplate.setHashKeySerializer(stringSerializer);// Hash key 序列化
redisTemplate.setHashValueSerializer(jackson2JsonRedisSerializer);// Hash value 序列化
redisTemplate.afterPropertiesSet();
return redisTemplate;
}
1
xiyangzh 2023-05-12 18:16:38 +08:00
是不是把现象描述详细。 无法序列化是序列化报错呢还是序列化的值有问题呢?
Jackson 的东西只听说过反序列化有问题,还是头一次听说序列化有问题的 |
2
awolf 2023-05-13 16:55:53 +08:00
redis 里面看过结果么?
|