I have a Spring boot
project - its parent is spring-boot-starter-parent:2.1.9.RELEASE
. I want to use the spring-data-redis
with 2.2.0.RELEASE
version (not the spring-boot-starter-data-redis
because this does not support redis-streams
). Also I use Lettuce
version io.lettuce:lettuce-core:5.2.0.RELEASE
.
My pom.xml
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.9.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
...
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-redis</artifactId>
<version>2.2.0.RELEASE</version>
</dependency>
<dependency>
<groupId>io.lettuce</groupId>
<artifactId>lettuce-core</artifactId>
<version>5.2.0.RELEASE</version>
</dependency>
However, I get the following error when run, though the application has no compilation errors.
***************************
APPLICATION FAILED TO START
***************************
Description:
An attempt was made to call a method that does not exist. The attempt was made from the following location:
org.springframework.data.redis.repository.configuration.RedisRepositoryConfigurationExtension.createMappingConfigBeanDef(RedisRepositoryConfigurationExtension.java:168)
The following method did not exist:
org/springframework/data/repository/config/RepositoryConfigurationSource.getRequiredAttribute(Ljava/lang/String;Ljava/lang/Class;)Ljava/lang/Object;
The method's class, org.springframework.data.repository.config.RepositoryConfigurationSource, is available from the following locations:
jar:file:/Users/user1/.m2/repository/org/springframework/data/spring-data-commons/2.1.11.RELEASE/spring-data-commons-2.1.11.RELEASE.jar!/org/springframework/data/repository/config/RepositoryConfigurationSource.class
It was loaded from the following location:
file:/Users/user1/.m2/repository/org/springframework/data/spring-data-commons/2.1.11.RELEASE/spring-data-commons-2.1.11.RELEASE.jar
Action:
Correct the classpath of your application so that it contains a single, compatible version of org.springframework.data.repository.config.RepositoryConfigurationSource
The spring-data-redis
is resolved to 2.1.11.release
version.
With the hint given by Dirk Deyne (who deleted those comments?), the spring-data-redis
version can be overriden with the expected version like this
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-redis</artifactId>
<version>2.2.0.RELEASE</version>
</dependency>
Having got other dependency issues because of this (error in question) specific version, have to add other libraries versions too, in this case
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-commons</artifactId>
<version>2.2.0.RELEASE</version>
</dependency>
and the
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-keyvalue</artifactId>
<version>2.2.0.RELEASE</version>
</dependency>