spring整合redis时出现的异常Error creating bean with name 'JedisConnectionFactory' defined in URL
异常如下:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘JedisConnectionFactory’ defined in URL [jar:file:/D:/DevelopTools/maven_repository/com/pinyougou/pinyougou-common/1.0-SNAPSHOT/pinyougou-common-1.0-SNAPSHOT.jar!/spring/applicationContext-redis.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:1578)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
…
这个时候的话可以去检查一下自己jar里面的spring-data-redis和 jedis版本是否对应,例如我的
我的spring-data-redis版本为2.2.1.RELEASE,之后的话,你可以去maven库搜一下spring-data-redis:2.2.1.RELEASE对应的jedis最低版本为多少
## 步骤
进入网址https://mvnrepository.com,如图搜索
进去之后找到你自己的版本号,例如我的版本2.2.1
点进去之后,你往下滑,就可以看到相应版本对应的jedis最低版本啦。
之后在项目中填好相应配置,即可。