Как использовать другую версию весеннего модуля (spring-data-redis) в конкретной версии загрузочной пружины - PullRequest
2 голосов
/ 16 октября 2019

У меня есть проект Spring boot - его родитель spring-boot-starter-parent:2.1.9.RELEASE. Я хочу использовать spring-data-redis с 2.2.0.RELEASE версией (не spring-boot-starter-data-redis, потому что это не поддерживает redis-streams). Также я использую Lettuce версию 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>

Однако при запуске я получаю следующую ошибку, хотя в приложении нет ошибок компиляции.

***************************
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 версии.

1 Ответ

0 голосов
/ 17 октября 2019

С подсказкой Дирка Дейна (который удалил эти комментарии?), Версия spring-data-redis может быть переопределена ожидаемой версией, подобной этой

    <dependency>
        <groupId>org.springframework.data</groupId>
        <artifactId>spring-data-redis</artifactId>
        <version>2.2.0.RELEASE</version>
    </dependency>

Из-за этого возникли другие проблемы с зависимостями (ошибка, о которой идет речь) конкретная версия, необходимо добавить и другие версии библиотек, в этом случае

    <dependency>
        <groupId>org.springframework.data</groupId>
        <artifactId>spring-data-commons</artifactId>
        <version>2.2.0.RELEASE</version>
    </dependency>

и

     <dependency>
        <groupId>org.springframework.data</groupId>
        <artifactId>spring-data-keyvalue</artifactId>
        <version>2.2.0.RELEASE</version>
    </dependency>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...