首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在具体的spring boot版本中使用不同的spring模块(spring-data-redis)版本

如何在具体的spring boot版本中使用不同的spring模块(spring-data-redis)版本
EN

Stack Overflow用户
提问于 2019-10-17 00:02:47
回答 1查看 1.5K关注 0票数 3

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

我的pom.xml

代码语言:javascript
复制
     <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>

但是,尽管应用程序没有编译错误,但我在运行时得到了以下错误。

代码语言:javascript
复制
***************************
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版本。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-10-17 15:03:10

在Dirk Deyne (谁删除了这些评论?)的提示下,spring-data-redis版本可以被预期的版本覆盖,如下所示

代码语言:javascript
复制
    <dependency>
        <groupId>org.springframework.data</groupId>
        <artifactId>spring-data-redis</artifactId>
        <version>2.2.0.RELEASE</version>
    </dependency>

由于这个(有问题的错误)特定版本,我得到了其他依赖问题,在这种情况下,还必须添加其他库版本

代码语言:javascript
复制
    <dependency>
        <groupId>org.springframework.data</groupId>
        <artifactId>spring-data-commons</artifactId>
        <version>2.2.0.RELEASE</version>
    </dependency>

代码语言:javascript
复制
     <dependency>
        <groupId>org.springframework.data</groupId>
        <artifactId>spring-data-keyvalue</artifactId>
        <version>2.2.0.RELEASE</version>
    </dependency>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58417448

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档