[Exception]redis.clients.jedis.exceptions.JedisConnectionException

时间:2021-07-29 13:59:22

情形1:对应的服务器没有开启 (redis server 没有启动)
启动命令:mac: redis-server

redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool
    at redis.clients.util.Pool.getResource(Pool.java:40)
    at com.hadoit.game.common.framework.nosql.redis.JedisDataSource.getResource(JedisDataSource.java:96)
    at com.hadoit.game.common.framework.nosql.redis.JedisTemplate.getJedis(JedisTemplate.java:63)
    at com.hadoit.game.common.framework.nosql.redis.JedisTemplate.execute(JedisTemplate.java:77)
    at com.gamejelly.gong.tools.HefuDataTools.getBAllLltRankData(HefuDataTools.java:548)
    at com.gamejelly.gong.tools.HefuDataTools.handleLltRank(HefuDataTools.java:487)
    at com.gamejelly.gong.tools.HefuDataTools.main(HefuDataTools.java:468)
Caused by: redis.clients.jedis.exceptions.JedisConnectionException: java.net.ConnectException: Connection refused
    at redis.clients.jedis.Connection.connect(Connection.java:137)
    at redis.clients.jedis.BinaryClient.connect(BinaryClient.java:65)
    at redis.clients.jedis.BinaryJedis.connect(BinaryJedis.java:1706)
    at redis.clients.jedis.JedisFactory.makeObject(JedisFactory.java:28)
    at org.apache.commons.pool.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:1188)
    at redis.clients.util.Pool.getResource(Pool.java:38)
    ... 6 more
Caused by: java.net.ConnectException: Connection refused
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
    at java.net.Socket.connect(Socket.java:579)
    at redis.clients.jedis.Connection.connect(Connection.java:132)
    ... 11 more

情形2:密码不正确,未能正确连接
解决方法1: 开启redis-cli 设置密码
Mac 下
[Exception]redis.clients.jedis.exceptions.JedisConnectionException
解决方法2: 修改项目对应配置的密码为空(默认没有密码)

redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool
    at redis.clients.util.Pool.getResource(Pool.java:40)
    at com.hadoit.game.common.framework.nosql.redis.JedisDataSource.getResource(JedisDataSource.java:96)
    at com.hadoit.game.common.framework.nosql.redis.JedisTemplate.getJedis(JedisTemplate.java:63)
    at com.hadoit.game.common.framework.nosql.redis.JedisTemplate.execute(JedisTemplate.java:77)
    at com.hadoit.game.common.framework.nosql.redis.JedisTemplate.get(JedisTemplate.java:257)
    at com.gamejelly.gong.dbs.service.GameService.touchJedis(GameService.java:68)
    at com.gamejelly.gong.dbs.proxy.DbsServerProxySqlImpl.onRegistered(DbsServerProxySqlImpl.java:42)
    at com.hadoit.game.engine.guardian.dbs.DbsManager.doStart(DbsManager.java:97)
    at com.hadoit.game.engine.guardian.core.GuardianContainer.start(GuardianContainer.java:123)
    at com.gamejelly.gong.dbs.DbsApp.main(DbsApp.java:32)
Caused by: redis.clients.jedis.exceptions.JedisDataException: ERR Client sent AUTH, but no password is set
    at redis.clients.jedis.Protocol.processError(Protocol.java:66)
    at redis.clients.jedis.Protocol.process(Protocol.java:73)
    at redis.clients.jedis.Protocol.read(Protocol.java:138)
    at redis.clients.jedis.Connection.getStatusCodeReply(Connection.java:165)
    at redis.clients.jedis.BinaryJedis.auth(BinaryJedis.java:2104)
    at redis.clients.jedis.JedisFactory.makeObject(JedisFactory.java:30)
    at org.apache.commons.pool.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:1188)
    at redis.clients.util.Pool.getResource(Pool.java:38)
    ... 9 more