开发者社区> 问答> 正文

redis2.9.0与spring1.3.4版本冲突问题?报错

redis一定是要用redis-2.9.0版本的,spring用的是1.3.4版本,然后调用时报错,日志如下:

spring/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: redis.clients.jedis.JedisShardInfo.setTimeout(I)V
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1455)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519),

网上找了下问题,说redis版本太高,要低于2.6.2版本一下,但是实际情况改不了redis版本,这种情况怎么解决呢

展开
收起
爱吃鱼的程序员 2020-06-08 13:15:43 778 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    Exceptioninthread"main"org.springframework.beans.factory.BeanCreationException:Errorcreatingbeanwithname'jedisConnectionFactory'definedinfile[/home/spring/applicationContext.xml]:Invocationofinitmethodfailed;nestedexceptionisjava.lang.NoSuchMethodError:redis.clients.jedis.JedisShardInfo.setTimeout(I)V

       atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1455)
       atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
       atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)

     

    applicationContext.xml配置如下:

    <beanid="jedisConnectionFactory"class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory"><propertyname="hostName"value="${redis.localhost}"/><propertyname="port"value="${redis.port}"/><propertyname="timeout"value="${redis.timeout}"/><propertyname="poolConfig"ref="localJedisPoolConfig"/></bean>

    那就改spring的版本喽

    嗯只能这样了
    2020-06-08 13:15:53
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
云栖社区特邀专家徐雷Java Spring Boot开发实战系列课程(第20讲):经典面试题与阿里等名企内部招聘求职面试技巧 立即下载
微服务架构模式与原理Spring Cloud开发实战 立即下载
阿里特邀专家徐雷Java Spring Boot开发实战系列课程(第18讲):制作Java Docker镜像与推送到DockerHub和阿里云Docker仓库 立即下载