redis.clients.jedis.exceptions.InvalidURIException: Cannot open Redis connection due invalid URI

来源:互联网 发布:企业网络搭建论文 编辑:程序博客网 时间:2024/05/26 12:07

在tomcat 里面部署启动程序报错:

本地开发,连的redis没有任何问题,部署到Linux机器上就开始提示

redis.clients.jedis.exceptions.InvalidURIException: Cannot open Redis connection due invalid URI

开始以为是redis安装的有问题,各种调试试错,发现都是正常

以下是问题截图:

这里写图片描述

追源码发现是使用spring初始化JedisPool时未指定结构方法参数的类型导致了,初始化对象时跑到了别的初始化话方法上

<bean id="jedisPoolConfig" class="redis.clients.jedis.JedisPoolConfig">        <!--最大连接数 -->        <property name="maxTotal" value="5000" />        <!--最大空闲连接数 -->        <property name="maxIdle" value="100" />        <!--初始化连接数 -->        <property name="minIdle" value="100" />        <!--最大等待时间 -->        <property name="maxWaitMillis" value="1000" />        <!--定时对线程池中空闲的链接进行validateObject校验 -->        <property name="testWhileIdle" value="true" />         <property name="testOnBorrow" value="true" />        <!--在进行returnObject对返回的connection进行validateObject校验 -->        <property name="testOnReturn" value="true" />    </bean>    <bean id="jedisPool" class="redis.clients.jedis.JedisPool" destroy-method="destroy">        <constructor-arg index="0" ref="jedisPoolConfig" />        <constructor-arg index="1" value="192.168.12.123"   />        <constructor-arg index="2" value="6379" type="int" />        <constructor-arg index="3" value="2000" type="int" />    </bean>

如果constructor-arg 未指定type 初始化的时候JedisPool有两个相同参数个数的构造方法会选择错误,造成类似于这样的错误。

<constructor-arg index="1" value="192.168.12.123"   type="java.lang.String"/>
JedisPool(GenericObjectPoolConfig, String, int)  
2 0
原创粉丝点击