今天在将redis和spring整合到一起是遇到了以下错误:
错误提示:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'redisTemplate' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: org.springframework.core.serializer.support.DeserializingConverter.<init>(Ljava/lang/ClassLoader;)
省略。。。。。
Caused by: java.lang.NoSuchMethodError: org.springframework.core.serializer.support.DeserializingConverter.<init>(Ljava/lang/ClassLoader;)V
一般的,NoSuchMethodError
,都是因为没有导入相应的包。
经过检查,是Spring
的版本和spring-data-redis.jar
的版本的冲突导致的。
原本的spring
版本:
spring-data-redis
的版本1.7.2
:
<!-- https://mvnrepository.com/artifact/org.springframework.data/spring-data-redis -->
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-redis</artifactId>
<version>1.7.2.RELEASE</version>
</dependency>
改正方法:
将spring版本更新为:4.3.2.