redis.clients.jedis.exceptions.JedisException: Could not get a resource from the pool
at redis.clients.util.Pool.getResource(Pool.java:51)
at redis.clients.jedis.JedisPool.getResource(JedisPool.java:226)
at io.codis.jodis.RoundRobinJedisPool.getResource(RoundRobinJedisPool.java:218)
at com.br.hermes.center.service.impl.IndexServiceV3Impl.initLimitProductMap(IndexServiceV3Impl.java:2780)
at com.br.hermes.center.quartz.SendMailQuartz.refreshFlowControllConfig(SendMailQuartz.java:608)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:65)
at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
at org.springframework.scheduling.concurrent.ReschedulingRunnable.run(ReschedulingRunnable.java:81)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:266)
at java.util.concurrent.FutureTask.run(FutureTask.java)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.util.NoSuchElementException: Unable to validate object
at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:506)
at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:363)
at redis.clients.util.Pool.getResource(Pool.java:49)
... 19 more
我的初始化连接池代码:
@Configuration
public class CodisClientHA {
private Logger logger = LogManager.getLogger(CodisClientHA.class);
@Value("${codis.zkAddr}")
private String zkAddr;
@Value("${codis.zk.proxy.dir}")
private String zkProxyDir;
@Value("${codis.password}")
private String password;
@Value("${codis.timeout}")
private int timeout;
@Value("${codis.maxActive}")
private int max_active;
@Value("${codis.maxIdle}")
private int max_idle;
@Value("${codis.minIdle}")
private int min_idle;
@Value("${codis.maxWait}")
private long max_wait;
@Bean
public JedisResourcePool getPool() {
JedisPoolConfig poolConfig = new JedisPoolConfig();
poolConfig.setMaxIdle(max_idle);
poolConfig.setMaxTotal(max_active);
poolConfig.setTestOnBorrow(true);
poolConfig.setTestOnReturn(true);
poolConfig.setMaxWaitMillis(max_wait);
poolConfig.setBlockWhenExhausted(false);
JedisResourcePool pool = RoundRobinJedisPool.create().poolConfig(poolConfig)
.curatorClient(zkAddr, timeout).zkProxyDir(zkProxyDir).build();
logger.info("------------------- Codis connection pool init succeed -------------------");
return pool;
}
我自己新创建的spring boot 测试codis项目没问题,将codis初始化连接池代码放到实际项目(spring mvc)中,就会报错,请问是怎么回事? 哪位大神帮帮忙,谢谢🙏 报错如下:
我的初始化连接池代码:
配置:
使用时: