Reputation: 574
I have upgraded spring boot version from 2.5.3 to 2.5.5 which has upgraded this libraries.
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
with this upgrade, I started getting an error: java.lang.NoSuchMethodError:kafka.server.KafkaServer.(Lkafka/server/KafkaConfig; Lorg/apache/common/kafka/utils/Time;Lscala/Option;/Lscala/collection/Seq;)V
I had tried a lot with changing the version as required by compatibility matrix of spring docs https://spring.io/projects/spring-kafka
Any idea what could be the issue?
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>
Upvotes: 0
Views: 4698
Reputation: 174574
Whenever you specify a version for kafka-clients rather than letting boot prescribe the version; you must also override the versions of the kafka jars used by the embedded broker.
https://docs.spring.io/spring-kafka/docs/current/reference/html/#update-deps
Upvotes: 2