Spring kafka 2.3.1 not supported in spring boot V2.1.9.RELEASE
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Spring Kafka is an integral part of the Spring ecosystem, enabling developers to build robust Kafka-based messaging solutions seamlessly integrated with other Spring functionalities such as Spring Boot. Given the tight coupling between Spring projects, version compatibility is a critical consideration.
Understanding the Issue with Spring Kafka 2.3.1 and Spring Boot 2.1.9.RELEASE
Spring Kafka 2.3.1, released in September 2019, came with several enhancements and bug fixes. However, it was primarily designed to work optimally with Spring Boot 2.2.x. When attempting to use Spring Kafka 2.3.1 with an older Spring Boot version like 2.1.9.RELEASE, developers might encounter compatibility issues.
The primary reason for these conflicts generally lies in dependency management and auto-configuration behaviors governed by Spring Boot’s internal mechanisms. Each Spring Boot version curates a selected list of dependencies that are tested to work seamlessly together, specified in its spring-boot-dependencies POM file. This list defines the versions that have not only been tested to ensure compatibility but also optimized to work with other components within the ecosystem.
Why Version Mismatches Lead to Problems
- Dependency Conflicts: Different versions of Spring Boot depend on specific versions of Kafka clients and Spring Kafka. Using a mismatched version can lead to classpath conflicts where different parts of an application might inadvertently use different versions of the same library.
- Auto-configuration Mismatches: Spring Boot relies extensively on auto-configuration, setting up necessary configurations based on the libraries present in the classpath. If Spring Kafka 2.3.1 expects or needs configurations or beans that aren’t provided or recognized by Spring Boot 2.1.9, it will lead to application startup failures.
- API Changes: APIs in Spring Kafka could have changed between the versions expected by the two different Spring Boot releases. Using incompatible versions can lead to NoSuchMethodErrors or similar issues at runtime.
Solutions and Workarounds
To resolve such issues, consider the following approaches:
- Upgrade Spring Boot: The most straightforward approach is upgrading the Spring Boot version to at least 2.2.x to ensure compatibility with Spring Kafka 2.3.1.
- Downgrade Spring Kafka: If upgrading Spring Boot is not feasible due to other dependency constraints, consider downgrading Spring Kafka to a version compatible with Spring Boot 2.1.9.
- Override Dependencies with Caution: Manually overriding the Kafka client versions used by Spring Kafka to match those bundled with Spring Boot 2.1.9 is risky but can work as a last resort. This approach requires thorough testing to ensure no unexpected runtime issues.
Technical Example: Dependency Management in Maven
For instance, in Maven, overriding a dependency version can be done within the pom.xml as follows:
Ensure that this version is compatible with the Kafka clients used in your project.
Summary Table: Compatibility and Solutions
| Aspect | Issue | Solution |
| Dependency Conflicts | Classpath issues due to different versions of dependencies. | Align versions via Spring Boot’s BOM or manage dependencies manually. |
| Auto-Configuration | Spring Kafka 2.3.1 may introduce beans not recognized by Spring Boot 2.1.9. | Upgrade Spring Boot or downgrade Spring Kafka. |
| API Changes | Runtime errors like NoSuchMethodError due to API mismatches. | Ensure API compatibility via proper version alignment. |
Conclusion
To mitigate risks and ensure a seamless development experience, it’s crucial to maintain version compatibility between Spring Boot and Spring Kafka. Regularly updating to newer versions of Spring Boot not only helps in leveraging the latest features but also in minimizing such conflicts.
Related reading
- Spring Kafka Always rebalance after 5 min even i pause consumer
- Spring Kafka and exactly once delivery guarantee
- Spring kafka and Kafka Cluster
- Spring Kafka and Kafka Streams
- Spring Kafka asynchronous send calls block
- Spring Kafka Auto Commit Offset In Case of Failures
- Spring Kafka configure number of partitions for topic
- Spring kafka Consume multiple Message types in one consumer

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.