@Autowired private RedisTemplate<String, String> redisTemplate;
方法里添加: JedisConnectionFactory connectionFactory =(JedisConnectionFactory) redisTemplate.getConnectionFactory(); //创建连接池 connectionFactory.setDatabase(6);//切换6号数据库
测试结果
JSONObject js = JSONObject.parseObject(redisTemplate.opsForValue().get("Cameras:23010900001310082943").toString());
注意是新版的将JedisConnectionFactory 换成 LettuceConnectionFactory