public class JedisPoolConfig extends GenericObjectPoolConfig {
public JedisPoolConfig() {
// defaults to make your life with connection pool easier :)
setTestWhileIdle(true);
setMinEvictableIdleTimeMillis(60000);
setTimeBetweenEvictionRunsMillis(30000);
setNumTestsPerEvictionRun(-1);
}
}
我的redis也是2.9.0,其他同学也都没报错,请仔细检查配置
JedisPoolWriper.java
package com.imooc.o2o.cache;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;
/**
* 强指定redis的JedisPool接口构造函数,这样才能在centos成功创建jedispool
*
* @author xiangze
*
*/
public class JedisPoolWriper {
/** Redis连接池对象 */
private JedisPool jedisPool;
public JedisPoolWriper(final JedisPoolConfig poolConfig, final String host,
final int port) {
try {
jedisPool = new JedisPool(poolConfig, host, port);
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 获取Redis连接池对象
* @return
*/
public JedisPool getJedisPool() {
return jedisPool;
}
/**
* 注入Redis连接池对象
* @param jedisPool
*/
public void setJedisPool(JedisPool jedisPool) {
this.jedisPool = jedisPool;
}
}