Override Spring Boot Dependencies
When using Spring for Apache Kafka in a Spring Boot application, the Apache Kafka dependency versions are determined by Spring Boot’s dependency management.
If you wish to use a different version of kafka-clients
or kafka-streams
, and use the embedded kafka broker for testing, you need to override their version used by Spring Boot dependency management; set the kafka.version
property.
Default kafka-clients dependencies for Spring Boot 3.0.x and 3.1.x are 3.3.2 and 3.4.1 respectively.
|
Or, to use a different Spring for Apache Kafka version with a supported Spring Boot version, set the spring-kafka.version
property.
-
Maven
-
Gradle
<properties>
<kafka.version>3.5.1</kafka.version>
<spring-kafka.version>3.1.5</spring-kafka.version>
</properties>
<dependency>
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka</artifactId>
</dependency>
<!-- optional - only needed when using kafka-streams -->
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-streams</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka-test</artifactId>
<scope>test</scope>
</dependency>
ext['kafka.version'] = '3.5.0'
ext['spring-kafka.version'] = '3.1.5'
dependencies {
implementation 'org.springframework.kafka:spring-kafka'
implementation 'org.apache.kafka:kafka-streams' // optional - only needed when using kafka-streams
testImplementation 'org.springframework.kafka:spring-kafka-test'
}
The test scope dependencies are only needed if you are using the embedded Kafka broker in tests.