尝试将 Kafka 活页夹映射到输入法时出现 NoSuchMethodError

NoSuchMethodError when trying to map Kafka binder to input method

在 Kafka 活页夹处于活动状态的情况下尝试启动 spring 云流项目时,控制台会提示以下内容:

org.springframework.context.ApplicationContextException: Failed to start bean 'inputBindingLifecycle';
Caused by: java.lang.NoSuchMethodError: java.util.List.of(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/List;

我的输入法使用 Spring 云函数如下:

    @Bean
    public Function<Message<String>, byte[]> exec() {
        return input -> ...

现在,有了 Kafka,我的 .properties 文件如下所示:

spring.cloud.stream.function.bindings.exec-in-0=in
spring.cloud.stream.bindings.in.destination=topic-0
spring.cloud.stream.function.bindings.exec-out-0=out
spring.cloud.stream.bindings.out.destination=topic-1

spring.cloud.stream.bindings.in.binder=kafka
spring.cloud.stream.kafka.bindings.in.consumer.configuration.value.deserializer=org.apache.kafka.common.serialization.StringDeserializer

spring.cloud.stream.bindings.out.binder=kafka
spring.cloud.stream.kafka.bindings.out.producer.configuration.value.serializer=org.apache.kafka.common.serialization.ByteArraySerializer

我是否遗漏了输入法的任何配置?对于 Kafka,该方法是否应该有所不同(已经用 PubSub 测试过并且有效)?

您的堆栈跟踪中的错误为我们提供了您面临此问题的线索:https://github.com/spring-projects/spring-integration/issues/3761

所以,还是升级到最新的Spring云流:https://spring.io/projects/spring-cloud-stream#learn

或到最新的Spring集成:https://spring.io/projects/spring-integration#learn

或者只使用 Java > 8 !