spring-boot - Spring Cloud Streams-以下方法不存在

标签 spring-boot gradle apache-kafka spring-cloud-stream

当前,我们正在尝试制作一个能够产生有关主题的某些消息的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
我们认为spring-boot和SCS存在兼容性问题。我们正在使用spring-boot版本:2.2.2-RELEASE他已经将SCS的版本更改为Hoxton 2,再回到Hoxton 6,还尝试更改了spring-kafka版本,使其包含方法setBeanName。更改spring-kafka版本时,我们使用不同的方法遇到了类似的错误。这是我的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}"
    }
问题(我们认为)是spring-kafka从其他地方插入,默认为2.3.4.RELEASE,其中不包含setBeanName。
有什么想法吗?

最佳答案

您需要在应用程序中将spring-kafka依赖项更新为2.3.10.BUILD-SNAPSHOT才能解决此问题。明天(07/22/2020),它将被释放(2.3.10.RELEASE),它将由Spring Boot 2.2.9.RELEASE(计划于07/23/2020)引入。因此,当该Boot版本可用时,您应该更新您的应用程序以使用该版本(2.2.9.REELASE)。

关于spring-boot - Spring Cloud Streams-以下方法不存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63018778/

相关文章:

java - 如何在不修改整个响应的情况下返回基于 HATEOAS 的 URL?

java - Spring Boot中数据库测试之前有条件设置@Activeprofile

java - Dockerized SpringBoot REST api 不支持请求方法 'GET'

java - 如何使用@Transactional修复LazyInitializationException?

apache-kafka - 重新启动集群时连接消费者作业被删除

Android Studio 和 Gradle - 关于 testCompile、testImplementation、testApi 的看似误导性警告

gradle - 如何将检查样式添加到libGDX项目?

java - Gradle SourceSet IntelliJ 与 Eclipse

apache-kafka - Kafka如何为key选择分区?

java - 如何在由KafkaTemplate创建的事务中发送Kafka偏移量?