exceptions.JedisConnectionException: Could not get a resource from the pool at org.springframework.

来源:互联网 发布:数控编程帅气宝塔图纸 编辑:程序博客网 时间:2024/05/21 17:51

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 status
  • 1

暂时关闭防火墙:

/etc/init.d/iptables stop
  • 1

禁止防火墙在系统启动时启动

/sbin/chkconfig --level 2345 iptables off
  • 1

解决方法二: 
将redis.conf中的bind 127.0.0.1注释掉


阅读全文
0 0
原创粉丝点击