我们目前正在尝试制作一个scs应用程序,该应用程序向某个主题生成某些消息,但是在运行该应用程序时遇到以下错误:
The following method did not exist:
org.springframework.kafka.core.DefaultKafkaProducerFactory.setBeanName(Ljava/lang/String;)V
The method's class, org.springframework.kafka.core.DefaultKafkaProducerFactory, is available from the following locations:
jar:file:/C:/Users/Me/.gradle/caches/modules-2/files-2.1/org.springframework.kafka/spring-kafka/2.3.4.RELEASE/65f92192fc57991d4b135c715be5a506b3153ea1/spring-kafka-2.3.4.RELEASE.jar!/org/springframework/kafka/core/DefaultKafkaProducerFactory.class
It was loaded from the following location:
file:/C:/Users/Me/.gradle/caches/modules-2/files-2.1/org.springframework.kafka/spring-kafka/2.3.4.RELEASE/65f92192fc57991d4b135c715be5a506b3153ea1/spring-kafka-2.3.4.RELEASE.jar
Action:
Correct the classpath of your application so that it contains a single, compatible version of org.springframework.kafka.core.DefaultKafkaProducerFactory
我们认为SpringBoot和scs存在兼容性问题。我们使用的是spring-boot版本:2.2.2-release他把我们的scs版本改成了hoxton 2,又改回了hoxton 6,还试着把spring-kafka的版本控制改成包含setbeanname方法。在更改SpringKafka版本时,我们使用不同的方法遇到了类似的错误。以下是我的gradle依赖项:
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.cloud:spring-cloud-stream'
implementation 'org.springframework.cloud:spring-cloud-stream-binder-kafka'
implementation 'org.springframework.kafka:spring-kafka'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-xml'
以下是依赖关系管理:
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
问题(我们认为)是SpringKafka从其他地方被拉进来,并默认为2.3.4.release,它不包含setbeanname。
有什么想法吗?
2条答案
按热度按时间tv6aics11#
我们能够通过切换到springboot2.3.1.release来缓解我们的问题
44u64gxh2#
您需要将spring-kafka依赖项更新为
2.3.10.BUILD-SNAPSHOT
在应用中解决这个问题。明天(07/22/2020),它将被发布(2.3.10.RELEASE
),它将被Spring Boot拉进来2.2.9.RELEASE
(计划于2020年7月23日发布)。因此,当启动版本可用时,应该更新应用程序以使用该版本(2.2.9.REELASE
).