According to compatibility matrix https://spring.io/projects/spring-kafka kafka-spring-test v2.7.12 should work with kafka-clients 2.7.0 - 2.8.1 but I'm getting runtime exceptions during embedded kafka tests. pom.xml
<dependencies>
...
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-clients</artifactId>
<version>2.8.1</version>
<exclusions>
<exclusion>
<artifactId>jmxri</artifactId>
<groupId>com.sun.jmx</groupId>
</exclusion>
<exclusion>
<artifactId>jms</artifactId>
<groupId>javax.jms</groupId>
</exclusion>
<exclusion>
<artifactId>jmxtools</artifactId>
<groupId>com.sun.jdmk</groupId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>5.3.17</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>5.3.17</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka</artifactId>
<version>2.7.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka-test</artifactId>
<version>2.7.12</version>
<scope>test</scope>
</dependency>
</dependencies>
Exception during runtime:
KafkaMsgFlowEmbeddedTest Time elapsed: 2.005 sec <<< ERROR!
java.lang.NoSuchMethodError: org.apache.kafka.common.protocol.ApiKeys.enabledApis()Ljava/util/List;
When I change kafka-clients to 2.7.2 all works fine. The problem is with 2.8.1. We are switching production to 2.8.1 so I need to test with this version of kafka-clients.
Could anyone advice how should I fix it?