请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

redis报Could not get a resource from the pool???

redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool


at redis.clients.util.Pool.getResource(Pool.java:53)

at redis.clients.jedis.JedisPool.getResource(JedisPool.java:226)

at com.java.itymd.utils.JedisUtil.getJedis(JedisUtil.java:57)

at com.java.itymd.utils.JedisUtil$Keys.exists(JedisUtil.java:227)

at com.java.itymd.service.impl.AreaServiceImpl.queryAreaList(AreaServiceImpl.java:51)

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.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:333)

at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)

at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)

at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)

at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:282)

at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)

at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)

at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213)

at com.sun.proxy.$Proxy21.queryAreaList(Unknown Source)

at test.service.AreaServiceTest.testQueryQrea(AreaServiceTest.java:24)

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.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)

at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)

at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)

at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)

at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75)

at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86)

at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84)

at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)

at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:252)

at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:94)

at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)

at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)

at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)

at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)

at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)

at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)

at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)

at org.junit.runners.ParentRunner.run(ParentRunner.java:363)

at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:191)

at org.junit.runner.JUnitCore.run(JUnitCore.java:137)

at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)

at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)

at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)

at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)

Caused by: redis.clients.jedis.exceptions.JedisConnectionException: java.net.SocketTimeoutException: connect timed out

at redis.clients.jedis.Connection.connect(Connection.java:207)

at redis.clients.jedis.BinaryClient.connect(BinaryClient.java:93)

at redis.clients.jedis.BinaryJedis.connect(BinaryJedis.java:1767)

at redis.clients.jedis.JedisFactory.makeObject(JedisFactory.java:106)

at org.apache.commons.pool2.impl.GenericObjectPool.create(GenericObjectPool.java:868)

at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:435)

at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:363)

at redis.clients.util.Pool.getResource(Pool.java:49)

... 46 more

Caused by: java.net.SocketTimeoutException: connect timed out

at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)

at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:85)

at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)

at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)

at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)

at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)

at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)

at java.net.Socket.connect(Socket.java:589)

at redis.clients.jedis.Connection.connect(Connection.java:184)

... 53 more


正在回答 回答被采纳积分+3

2回答

qq_轻摇滚_0 2018-04-20 12:13:10

老师太神勇了,把redis properties的ip改为127.0.0.1再部署到远程tomcat就可以读redis了。但是这个问题的原因实在没搞懂,既然远程服务器127.0.0.1和服务器的公网ip都是指向同个地址,为何公网ip就会出错呢?

另外发现了一个很小的瑕疵(算不上bug),我的项目和老师已经上线的项目都有。

如图,在商店详情页左上角有个返回按钮,但是按下去没有反应,不会退到上一级。

js源码onclick="javascript :history.back(-1);" 看起来没问题,为什么会无法实现回退功能呢?

https://img1.sycdn.imooc.com//szimg/5ad9683c0001947011252436.jpg

0 回复 有任何疑惑可以回复我~
  • 翔仔 #1
    同学好,我的redis直接用的公网ip是没问题的,可以看看你的redis是否开启本机公网服务,那个bind配置里面。。
    还有那个返回按钮是指返回之前打开的页面,如果是新页面的就没有路由没法返回了,但是正常使用过程中肯定不会不点开某个店铺列表再进入到该店铺的,所以正常使用情况下返回是能回到店铺列表页的,如果不是直接打开这个页面的话
    回复 有任何疑惑可以回复我~ 2018-04-20 16:09:38
  • 试了下自己的项目以及老师提供的二维码,从用户入口扫码开始进入frontend/index,一步步选择店铺进去,点击左上角的back键,真的还是没反应哦。老师可以试试呢
    回复 有任何疑惑可以回复我~ 2018-04-20 16:40:02
  • 同学试试 http://myo2o.yitiaojieinfo.com/myo2o/frontend/index  我的真没问题呢。。。
    回复 有任何疑惑可以回复我~ 2018-04-20 16:41:24
翔仔 2018-03-19 20:17:20

同学好,请问你的情况是刚配置了redis第一次访问就立马报错了还是之前好好的后面突然报错了,如果是前者,请与源码或者与视频比对,因为那是没有问题的,如果是后者,请参照https://www.jianshu.com/p/bb552ccc43b9解决

0 回复 有任何疑惑可以回复我~
  • 老师打扰了。我也遇到了同样问题。JedisConnectionException: Could not get a resource from the pool
    简书里所有的方法都试了还是没解决,配置也跟老师的一模一样(除了ip
    )。 本地机器redis cli和服务器redis cli去ping服务器的redis server都能立马得到pong,连接是没问题的
    而且很诡异的是,我在本地运行localhost tomcat,读取远程服务器的redis一点问题都没有。(redis properties定的端口一直都是远程)。 但是把一模一样的o2o.war scp到远程tomcat,运行时redis就会报错
    回复 有任何疑惑可以回复我~ 2018-04-20 10:50:02
  • 同学放上去后 看看tomcat log catalina.out 报的什么错,然后把ip改成127.0.0.1 然后再改成真正的ip试试 赞同学把问题描述得很清楚。
    回复 有任何疑惑可以回复我~ 2018-04-20 11:30:48
  • 以及尝试关闭并重启redis
    回复 有任何疑惑可以回复我~ 2018-04-20 11:31:39
问题已解决,确定采纳
还有疑问,暂不采纳
意见反馈 帮助中心 APP下载
官方微信