exceptions.JedisConnectionException: Could not get a resource from the pool at org.springframework.
2017-09-14 10:37
417 查看
exceptions.JedisConnectionException: Could not get a resource from the pool at org.springframework.
今天遇到奇葩问题:别人的项目说redis能给链接上,就我的不行。
排查思路:
一、检查redis是不是挂了
二、看看是不是防火墙开启
三、检查配置文件
我的问题出在配置文件上面,
系统里面有2套redis操作代码。
一套用的是“
redis.clients
jredis”
<dependency> <groupId>redis.clients</groupId> <artifactId>jedis</artifactId> <version>2.9.0</version> </dependency>
另一套用的是“
spring-boot-starter-redis
”
<!-- 集成redis --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-redis</artifactId> <version>1.4.3.RELEASE</version> <exclusions> <exclusion> <artifactId>jcl-over-slf4j</artifactId> <groupId>org.slf4j</groupId> </exclusion> <exclusion> <artifactId>jul-to-slf4j</artifactId> <groupId>org.slf4j</groupId> </exclusion> </exclusions> </dependency>
这2套的配置文件的host不一样,jredis用的叫hostName
而spring-boot-starter-redis用的叫host
所以链接不上,原因是根本就没有配host,解决办法就是陪2个,一个为host,一个为hostName 修改如下:
spring: redis: host: **.**.**.** hostName: **.**.**.** port: 6379 password: ****** pool: max-active: 8 max-wait: -1 max-idle: 8 min-idle: 0 timeout: 0 database: 4其他解决方案:
解决办法一:
1.关闭防火墙:
查看防火墙状态:
/etc/init.d/iptables status1
暂时关闭防火墙:
/etc/init.d/iptables stop1
禁止防火墙在系统启动时启动
/sbin/chkconfig --level 2345 iptables off1
解决方法二:
将redis.conf中的bind 127.0.0.1注释掉
相关文章推荐
- redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool
- 、redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool
- redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool
- 、redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool
- redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool
- redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool
- mm_redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool
- redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool
- redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool
- redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool
- spring boot 配置redis 启动报错:Cannot get Jedis connection;Could not get a resource from the pool
- redis JedisConnectionException: Could not get a resource from the pool
- 开发手记:JedisConnectionException: Could not get a resource from the pool
- Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nes
- org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection
- 关于jedis异常:Could not get a resource from the pool
- org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection;
- org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is org.apache.commons