redis data into the garbage problem solution

Step 1: Configure RedisTemplate

@Configuration
public class RedisConfigurtion {
@Autowired
private RedisTemplate redisTemplate;

@Bean(name = "redisTemplate")
public RedisTemplate<String, String> redisTemplate(RedisConnectionFactory factory) {
RedisTemplate<String, String> template = new RedisTemplate<>();
template.setConnectionFactory(factory);
template.setKeySerializer(new StringRedisSerializer());
template.setValueSerializer(new GenericJackson2JsonRedisSerializer());
template.setHashKeySerializer(new GenericJackson2JsonRedisSerializer());
template.setHashValueSerializer(new GenericJackson2JsonRedisSerializer());
template.afterPropertiesSet();
return template;
}
}

Step 2: Start CMD redis client

1. Open cmd window, enter chcp 65001 encoding formats provided cmd

2. Enter the directory and then enter the redis redis-cli.exe --raw start redis client

 

 

Guess you like

Origin www.cnblogs.com/qingmuchuanqi48/p/12052319.html