<!-- Redis-Client -->
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>2.8.0</version>
</dependency>
<!-- spring-redis -->
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-redis</artifactId>
<version>1.6.4.RELEASE</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-pool2</artifactId>
<version>2.4.2</version>
</dependency>
//连接池配置
JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
jedisPoolConfig.setMinIdle(5);
jedisPoolConfig.setMaxTotal(10);
jedisPoolConfig.setMaxIdle(7);
//哨兵集群列表
Set<String> sentinels = new HashSet<String>(Arrays.asList("10.xxx.xxx.xxx:26379"));
//创建Jedis哨兵连接池
//master_server主redis的名称
//sentinels哨兵集群
//jedisPoolConfig Jedis连接池
//xxxx是连接Redis服务器的密码
JedisSentinelPool jedisPool = new JedisSentinelPool("master_server", sentinels, jedisPoolConfig, "xxxx");
//获取连接池
Jedis jedis = pool.getResource();
jedis.set("name", "Jerry");
String name= jedis.get("name");