开发者社区 问答 正文

jedis链接池怎么配置。。。?报错

jedis2.4.1上配置连接池,怎么都不能成功,

pool = new JedisPool(new JedisPoolConfig(),"localhost");

这一行会报错,为什么呢????

展开
收起
爱吃鱼的程序员 2020-06-14 20:40:11 493 分享 版权
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    报错具体信息呢?common-pool.jar引入了没?

    jredis是有依赖的。

    引的包错了,jedis2.4依赖的包改成了common-pool2.jar了 staticLoglogger=LogFactory.getLog(RedisClient.class);privatestaticJedisPoolpool=null;static{JedisPoolConfigconfig=newJedisPoolConfig();         config.setMaxTotal(100);        config.setMaxIdle(95);        config.setMinIdle(5);         config.setMaxWaitMillis(1000*10);        config.setTestOnBorrow(true);        pool=newJedisPool(config,Constant.REDIS_IP,Constant.REDIS_PORT);logger.info("redisip:"+Constant.REDIS_IP+",port:"+Constant.REDIS_PORT);}


    这样写

    thankyou!刚刚发现是引的包不对
    2020-06-14 20:40:27
    赞同 展开评论
问答分类:
问答地址: