如何在特定的Spring Boot版本中使用不同的spring模块(spring-data-redis)版本

问题描述 投票:1回答:1

我有一个Spring boot项目-它的父级是spring-boot-starter-parent:2.1.9.RELEASE。我想将spring-data-redis2.2.0.RELEASE版本一起使用(而不是spring-boot-starter-data-redis,因为它不支持redis-streams)。我也使用Lettuce版本io.lettuce:lettuce-core:5.2.0.RELEASE

但是,尽管应用程序没有编译错误,但运行时出现以下错误。

***************************
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

spring-data-redis解析为2.1.11.release版本。

java spring spring-boot spring-data-redis lettuce
1个回答
0
投票

您可以简单地用所需的版本覆盖默认的starter-version

   <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-data-redis</artifactId>
   </dependency>
    <dependency>
        <groupId>org.springframework.data</groupId>
         <artifactId>spring-data-redis</artifactId>
         <version>2.2.0.RELEASE</version>
     </dependency>
© www.soinside.com 2019 - 2024. All rights reserved.