1新增依赖
4.0.0
com.gc
redisDemo
0.0.1-SNAPSHOT
redis.clients
jedis
2.9.0
junit
junit
4.12
test
org.apache.commons
commons-pool2
2.4.2
由于使用的是jedis2.9 在使用jedisPool选择的是第三个构造jedisPool的方法
public JedisPool() {
this(Protocol.DEFAULT_HOST, Protocol.DEFAULT_PORT);
}
public JedisPool(final GenericObjectPoolConfig poolConfig, final String host) {
this(poolConfig, host, Protocol.DEFAULT_PORT, Protocol.DEFAULT_TIMEOUT, null,
Protocol.DEFAULT_DATABASE, null);
}
public JedisPool(String host, int port) {
this(new GenericObjectPoolConfig(), host, port, Protocol.DEFAULT_TIMEOUT, null,
Protocol.DEFAULT_DATABASE, null);
}
GenericObjectPoolConfig 中配置了默认的config信息 ,使用此方法初始化一个jedisPool连接池
package red