第一步:配置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; } }
第二步:用CMD启动redis客户端
1.打开cmd窗口,输入 chcp 65001设置cmd的编码格式
2.再进入redis的目录输入 redis-cli.exe --raw 启动redis客户端