This version is still in development and is not considered stable yet. For the latest stable version, please use Spring for Apache Kafka 3.3.6! |
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.
Both Spring Boot 3.5.x and 3.4.x use the kafka-clients version 3.8.x and if users need to use 3.9.x client, they have to manually upgrade it using the method below.
|
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>4.0.0</kafka.version>
<spring-kafka.version>4.0.0-SNAPSHOT</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'] = '4.0.0-SNAPSHOT'
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.