java - 如何在特定的spring boot版本中使用不同的spring模块(spring-data-redis)版本
问题描述
我有一个Spring boot
项目 - 它的父级是spring-boot-starter-parent:2.1.9.RELEASE
. 我想使用spring-data-redis
with2.2.0.RELEASE
版本(不是spring-boot-starter-data-redis
因为这不支持redis-streams
)。我也使用Lettuce
版本io.lettuce:lettuce-core:5.2.0.RELEASE
。
我的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
版本。
解决方案
根据 Dirk Deyne 给出的提示(谁删除了这些评论?),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>
推荐阅读
- rest - 在 POST API 调用中将正文中的参数传递给 Openstack Nova
- mongodb - 来自 Cloud Function 的 Redis ECONNRESET
- c - GCC fprintf:应该是 int(32 位)还是 char(8 位)?
- node.js - a href 在 Express 中丢失 Jade 中的相对目录
- excel - 在 Excel VBA 中使用动态范围自动填充表格
- php - 相同的 Jquery 验证申请注册和更新,但在远程电子邮件方法上遇到问题
- java - If 语句检测字符串中的某些单词
- pdf - Apache FOP 外部图形自动高度以适应页面
- powershell - 存储有错误的命令输出
- javascript - 未捕获的 ReferenceError:未定义 removeLine