想学习学习redis缓存技术,于是到网上copy到了一些代码,粘贴到ecplise上面,但是发现代码总是报错

The constructor JedisPool(GenericObjectPoolConfig, String, int, int, String) refers to the missing type GenericObjectPoolConfig

什么问题,我们不知道啊

想了半天发现是我引入了common-pool.jar这个包,但是没有buildpath,,也是醉了,

现在问题解决了

package com.wdg.util;import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;public class RedisUtil {//Redis服务器IPprivate static String ADDR = "127.0.0.1";//Redis的端口号private static int PORT = 6379;//访问密码,若你的redis服务器没有设置密码,就不需要用密码去连接private static String AUTH = "123456";//可用连接实例的最大数目,默认值为8;private static int MAX_TOTAL = 512;//控制一个pool最多有多少个状态为idle(空闲的)的jedis实例,默认值也是8。private static int MAX_IDLE = 50;//等待可用连接的最大时间,单位毫秒,默认值为-1,表示永不超时。private static long MAX_WAIT = 10000;private static int TIMEOUT = 10000;//在borrow一个jedis实例时,是否提前进行validate操作;如果为true,则得到的jedis实例均是可用的;private static boolean TEST_ON_BORROW = true;private static JedisPool jedisPool = null;/*** 初始化Redis连接池*/static {try {JedisPoolConfig config = new JedisPoolConfig();config.setMaxActive(MAX_TOTAL);config.setMaxIdle(MAX_IDLE);config.setMaxWait(MAX_WAIT);config.setTestOnBorrow(TEST_ON_BORROW);jedisPool=new JedisPool(config, ADDR, PORT);/*  jedisPool = new JedisPool(config, ADDR, PORT, TIMEOUT, AUTH);*/} catch (Exception e) {e.printStackTrace();}}/*** 获取Jedis实例* @return*/public synchronized static Jedis getJedis() {try {if (jedisPool != null) {Jedis jedis = jedisPool.getResource();return jedis;} else {return null;}} catch (Exception e) {e.printStackTrace();return null;}}/*** 释放jedis资源* @param jedis*/public static void returnResource(final Jedis jedis) {if (jedis != null) {jedisPool.returnResource(jedis);}}
}

引用了jar是:

commons-pool.jar

jedis-1.5.2.jar

如果大家想用着这两个jar可以到下面的地址去下载:

https://download.csdn.net/download/datouniao1/10313743

希望对你有所帮助

The constructor JedisPool(GenericObjectPoolConfig, String, int, int, String) refers to the missing t相关推荐

  1. 使用Swift将String转换为Int

    本文翻译自:Converting String to Int with Swift The application basically calculates acceleration by input ...

  2. C++实现int与string之间的相互转换

    2019独角兽企业重金招聘Python工程师标准>>> c++ 利用stringstream实现int与string类型的相互转换,记录在此,以备后用 #include<ios ...

  3. int[]到string[]的转换方法 Array.ConvertAll

    2019独角兽企业重金招聘Python工程师标准>>> using System; using System.Collections.Generic; //int[]到string[ ...

  4. JAVA 中 string 和 int 互相转化

    在实际开发工作中,有时候为因为一些特殊原因,做类型转换,今天说一下string类型和int类型之间的转换. 1 如何将字串 String 转换成整数 int? A. 有两个方法: 1. int i = ...

  5. string转int 等(转)

    int转string int n = 0; std::stringstream ss; std::string str; ss<<n; ss>>str; string转int ...

  6. c++中几种常见的类型转换。int与string的转换,float与string的转换以及string和long类型之间的相互转换。to_string函数的实现和应用。...

    1.string转换为int a.采用标准库中atoi函数,对于float和龙类型也都有相应的标准库函数,比如浮点型atof(),long型atol(). 他的主要功能是将一个字符串转化为一个数字,在 ...

  7. int/double/string使用

    在计算机中存储数据和儿童在抽屉中存放物品很类似. 例如: 要在计算机中存一个数字50,需要两句话. int a;  //将要放的物品告诉家长 a=50;  //将物品放到某个抽屉中 计算机存储变量的过 ...

  8. C++ int与string的相互转换(含源码实现)

    一.int转换成string Ⅰ.to_string函数 c++11标准增加了全局函数std::to_string: string to_string (int val); string to_str ...

  9. String和int 转换

    2019独角兽企业重金招聘Python工程师标准>>> 1 string转换为int 1.1 第一种是使用static方法,不会产生多余对象,但会抛异常 String s = &qu ...

最新文章

  1. Nucleus-SE迁移:未实现的设施和兼容性
  2. Python之Matplotlib画图方法
  3. POJ - 2187 Beauty Contest(最远点对)
  4. Exchange+2010实验手册
  5. Python面试题(第二篇)
  6. 在计算机中dos代表什么意思,Boot是什么意思
  7. 超60亿元,新华三领衔华为锐捷中兴中标中国移动高端路由器和交换机集采
  8. linux /dev
  9. Python使用pandas对数据进行差分运算
  10. 自动超频_超频的几种方式
  11. JAVA版村庄哨塔种子_我的世界:top16种子,出生5村庄、地狱堡垒、2哨塔和一堆遗迹...
  12. VC2005 运行库解析
  13. 频响函数和传递函数详解-工程实例
  14. cmd贪吃蛇(cmd贪吃蛇怎么做)
  15. 使用Gson序列化对象将属性值中“=”转为“\u003d”问题及解决
  16. 金山词霸笔试题目笔记
  17. html中倒计时函数,关于倒计时的函数
  18. 无法将数据库从SINGLE_USER模式切换回MULTI_USER模式(Error 5064),及查找SQL Server数据库中用户spid(非SQL Server系统spid)的方法...
  19. Facebook反爬虫注册策略分析及养号实战
  20. 操作系统中cpu如何工作

热门文章

  1. jQuery-this与$(this)的区别
  2. Smarty vs Twig: 性能对比
  3. 员工提出离职,称害怕猝死,HR却说:先猝死了再说!
  4. 平滑无损!引入Elasticsearch的系统架构实战
  5. 3分钟读懂!微服务分布式日志体系架构!
  6. 如何提升你的能力?给年轻程序员的几条建议
  7. 靠纯技术是否能渡过中年危机
  8. 精心安利8个良心好用的学习神器和办公神器
  9. 为什么把事情拖到最后做效率特别高?
  10. SCRUM敏捷实践—任务看板