最近开始学习redis,在网上找了写例子在本地运行,功能都跑的通,可是后台报错了:


org.springframework.dao.DataAccessResourceFailureException: Cannot get Jedis connection; nested exception is redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool

    atorg.springframework.data.redis.connection.jedis.JedisConnectionFactory.fetchJedisConnector(JedisConnectionFactory.java:101)

    atorg.springframework.data.redis.connection.jedis.JedisConnectionFactory.getConnection(JedisConnectionFactory.java:148)

    atorg.springframework.data.redis.connection.jedis.JedisConnectionFactory.getConnection(JedisConnectionFactory.java:41)

    atorg.springframework.data.redis.core.RedisConnectionUtils.doGetConnection(RedisConnectionUtils.java:81)

    atorg.springframework.data.redis.core.RedisConnectionUtils.getConnection(RedisConnectionUtils.java:53)

 

    atorg.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:150)

    atorg.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:133)

    atorg.springframework.data.redis.core.RedisTemplate.hasKey(RedisTemplate.java:451)

    atcom.hemei.util.RedisUtil.exists(RedisUtil.java:59)

    atcom.hemei.interceptor.MethodCacheInterceptor.invoke(MethodCacheInterceptor.java:79)

    atorg.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)

    atorg.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)

    atorg.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)

    atorg.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:621)

    atcom.hemei.service.UserService$$EnhancerByCGLIB$$b4c1f514.login(<generated>)

 

    atcom.hemei.controller.UserController.login(UserController.java:36)

    atsun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethod)

    atsun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

    atsun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

    atjava.lang.reflect.Method.invoke(Unknown Source)

    atorg.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)

    atorg.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:427)

    atorg.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:415)

    atorg.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:788)

    atorg.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:717)

 

    atorg.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)

    atorg.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560)

    atjavax.servlet.http.HttpServlet.service(HttpServlet.java:650)

    atjavax.servlet.http.HttpServlet.service(HttpServlet.java:731)

    atorg.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)

    atorg.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)

    atorg.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

    atorg.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)

    atorg.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)

    atorg.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)

    atorg.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)

 

    atorg.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)

    atorg.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)

    atorg.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)

    atorg.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)

    atorg.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)

    atorg.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)

 

    atorg.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)

    atorg.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:957)

    atorg.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)

    atorg.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:423)

    atorg.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1079)

    atorg.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:620)

    atorg.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2516)

    atorg.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2505)

    atjava.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)

    atjava.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

    atorg.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)

    atjava.lang.Thread.run(Unknown Source)

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

 

    atredis.clients.util.Pool.getResource(Pool.java:22)

    atorg.springframework.data.redis.connection.jedis.JedisConnectionFactory.fetchJedisConnector(JedisConnectionFactory.java:94)

    ...53 more

Caused by: redis.clients.jedis.exceptions.JedisDataException: ERR Client sent AUTH, but no password is set

 

    atredis.clients.jedis.Protocol.processError(Protocol.java:55)

    atredis.clients.jedis.Protocol.process(Protocol.java:62)

    atredis.clients.jedis.Protocol.read(Protocol.java:127)

    atredis.clients.jedis.Connection.getStatusCodeReply(Connection.java:162)

    atredis.clients.jedis.Jedis.auth(Jedis.java:1955)

    atredis.clients.jedis.JedisPool$JedisFactory.makeObject(JedisPool.java:66)

    atorg.apache.commons.pool.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:840)

    atredis.clients.util.Pool.getResource(Pool.java:20)

    ...54 more

com.hemei.service.UserService_getUserByPageNo_1

org.springframework.dao.DataAccessResourceFailureException: Cannot get Jedis connection; nested exception is redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool

    atorg.springframework.data.redis.connection.jedis.JedisConnectionFactory.fetchJedisConnector(JedisConnectionFactory.java:101)

    atorg.springframework.data.redis.connection.jedis.JedisConnectionFactory.getConnection(JedisConnectionFactory.java:148)

    atorg.springframework.data.redis.connection.jedis.JedisConnectionFactory.getConnection(JedisConnectionFactory.java:41)

    atorg.springframework.data.redis.core.RedisConnectionUtils.doGetConnection(RedisConnectionUtils.java:81)

    atorg.springframework.data.redis.core.RedisConnectionUtils.getConnection(RedisConnectionUtils.java:53)

 

    atorg.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:150)

    atorg.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:133)

    atorg.springframework.data.redis.core.RedisTemplate.hasKey(RedisTemplate.java:451)

    atcom.hemei.util.RedisUtil.exists(RedisUtil.java:59)

    atcom.hemei.interceptor.MethodCacheInterceptor.invoke(MethodCacheInterceptor.java:79)

    atorg.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)

 

    atorg.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)

    atorg.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)

    atorg.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:621)

    atcom.hemei.service.UserService$$EnhancerByCGLIB$$b4c1f514.getUserByPageNo(<generated>)

    atcom.hemei.controller.UserController.list(UserController.java:116)

 

    atsun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethod)

    atsun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

    atsun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

 

    atjava.lang.reflect.Method.invoke(Unknown Source)

    atorg.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)

    atorg.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:427)

    atorg.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:415)

    atorg.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:788)

    atorg.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:717)

    atorg.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)

    atorg.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549)

    atjavax.servlet.http.HttpServlet.service(HttpServlet.java:624)

    atjavax.servlet.http.HttpServlet.service(HttpServlet.java:731)

    atorg.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)

    atorg.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)

    atorg.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

 

    atorg.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)

    atorg.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)

    atorg.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)

    atorg.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)

    atorg.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)

    atorg.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)

    atorg.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)

    atorg.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)

 

    atorg.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)

    atorg.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)

    atorg.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)

 

    atorg.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:957)

    atorg.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)

    atorg.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:423)

    atorg.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1079)

    atorg.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:620)

 

    atorg.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2516)

    atorg.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2505)

    atjava.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)

    atjava.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

    atorg.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)

 

    atjava.lang.Thread.run(Unknown Source)

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

    atredis.clients.util.Pool.getResource(Pool.java:22)

    atorg.springframework.data.redis.connection.jedis.JedisConnectionFactory.fetchJedisConnector(JedisConnectionFactory.java:94)

    ...53 more

Caused by: redis.clients.jedis.exceptions.JedisDataException: ERR Client sent AUTH, but no password is set

 

    atredis.clients.jedis.Protocol.processError(Protocol.java:55)

 

    atredis.clients.jedis.Protocol.process(Protocol.java:62)

    atredis.clients.jedis.Protocol.read(Protocol.java:127)

    atredis.clients.jedis.Connection.getStatusCodeReply(Connection.java:162)

    atredis.clients.jedis.Jedis.auth(Jedis.java:1955)

    atredis.clients.jedis.JedisPool$JedisFactory.makeObject(JedisPool.java:66)

    atorg.apache.commons.pool.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:840)

    atredis.clients.util.Pool.getResource(Pool.java:20)

    ...54 more



通过在网上查找相关博客,发现是redis没有设置密码,而程序中却传了密码,导致改异常,去掉密码即可