0

我已将 spring boot 版本从 2.5.3 升级到 2.5.5,它已经升级了这个库。

spring-kafka         : from 2.7.4 to 2.7.7
spring-kafka-test    : from 2.7.4 to 2.7.7
kafka-clients        : from 2.7.1 to 2.8.1
spring-test          : from 5.3.9 to 5.3.10

通过这次升级,我开始收到一个错误:java.lang.NoSuchMethodError:kafka.server.KafkaServer.(Lkafka/server/KafkaConfig; Lorg/apache/common/kafka/utils/Time;Lscala/Option;/Lscala/collection/序列;)V

我已经尝试了很多根据spring docs的兼容性矩阵的要求更改版本https://spring.io/projects/spring-kafka

知道可能是什么问题吗?

pom.xml (spring-boot 2.5.5)

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.kafka</groupId>
        <artifactId>spring-kafka</artifactId>
        <version>2.7.7</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.kafka</groupId>
        <artifactId>spring-kafka-test</artifactId>
        <version>2.7.7</version>
    </dependency>
    <dependency>
        <groupId>io.confluent</groupId>
        <artifactId>kafka-connect-replicator</artifactId>
        <version>5.3.4</version>
        <scope>runtime</scope>
        <exclusions>
          <exclusion>
           <groupId>org.apache.kafka</groupId>
           <artifactId>kafka_2.11</artifactId>
          </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>io.confluent</groupId>
        <artifactId>kafka-avro-serializer</artifactId>
        <version>5.5.1</version>
        <exclusions>
          <exclusion>
           <groupId>org.apache.kafka</groupId>
           <artifactId>kafka-clients</artifactId>
          </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-databind</artifactId>
    </dependency>

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-test</artifactId>
    <scope>test</scope>
</dependency>

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-test</artifactId>
    <scope>test</scope>
</dependency>
4

1 回答 1

1

每当您为 kafka-clients 指定版本而不是让引导指定版本时;您还必须覆盖嵌入式代理使用的 kafka jar 版本。

https://docs.spring.io/spring-kafka/docs/current/reference/html/#update-deps

于 2021-10-18T20:09:04.820 回答