The constructor JedisPool(GenericObjectPoolConfig, String, int) refers to the missing type GenericObjectPoolConfig
并且JedisPoolConfig创建的对象 没有setMaxTotal,setMaxIdle 等方法.
查看JedisPoolConfig

GenericObjectPoolConfig 这个类没有找到
原因:
commons-pool.jar 错误,因为GenericObjectPoolConfig 这个方法只有在commons-pool2.jar中才有。
commons-pool2.jar的下载地址:
http://commons.apache.org/proper/commons-pool/download_pool.cgi
代码如下
public void demo2() {
JedisPool jedisPool =null;
Jedis jedis=null;
try {
JedisPoolConfig config=new JedisPoolConfig();
config.setMaxTotal(200);
config.setMaxIdle(100);
config.setMaxWaitMillis(100*60);
jedisPool=new JedisPool(config,"127.0.0.1",6379);
jedis=jedisPool.getResource();
jedis.set("login-name", "张三");
String loginNameString= jedis.get("login-name");
System.out.println(loginNameString);
} catch (Exception e) {
// TODO: handle exception
}finally{
if(jedis!=null){
jedis.close();
}
if(jedisPool!=null){
jedisPool.close();
}
}
}
来源:https://www.cnblogs.com/choiyubo163com/p/7977829.html