Expected Behavior
When following the Spring for Apache Kafka reference documentation and
adding:
<dependency>
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka</artifactId>
</dependency>
in a Spring Boot 4 application, Kafka auto-configuration should be
activated.
Alternatively, the documentation should clearly state that
spring-boot-starter-kafka is required when using Spring Boot 4.
At minimum, it should explicitly mention that Spring Boot 4 users must
include:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-kafka</artifactId>
</dependency>
to enable:
- Auto-configuration
- Property binding for
spring.kafka.*
- Creation of
KafkaTemplate
- Listener container infrastructure (
@KafkaListener support)
Current Behavior
In Spring Boot 4.0.2, adding only:
<dependency>
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka</artifactId>
</dependency>
does not activate Kafka auto-configuration:
KafkaTemplate cannot be autowired
(No beans of type 'KafkaTemplate' found)
spring.kafka.* properties in application.yml are ignored
Using spring-boot-starter-kafka resolves the issue.
However, this requirement is not mentioned in the Spring for Apache
Kafka documentation.
Context
While setting up Kafka in a Spring Boot 4.0.2 project, I followed the
official Spring for Apache Kafka documentation and added only the
spring-kafka dependency.
This resulted in autowiring failures and missing property binding, which
was confusing because the documentation does not mention the need for
the Spring Boot starter.
I later discovered that Spring Initializr generates
spring-boot-starter-kafka for Boot 4 projects, and adding it fixes the
issue.
This can be particularly confusing for new users who rely on the Kafka
documentation directly rather than starting from Initializr.
A clarification in the documentation for Spring Boot 4 users would help
prevent this confusion.
Expected Behavior
When following the Spring for Apache Kafka reference documentation and
adding:
in a Spring Boot 4 application, Kafka auto-configuration should be
activated.
Alternatively, the documentation should clearly state that
spring-boot-starter-kafkais required when using Spring Boot 4.At minimum, it should explicitly mention that Spring Boot 4 users must
include:
to enable:
spring.kafka.*KafkaTemplate@KafkaListenersupport)Current Behavior
In Spring Boot 4.0.2, adding only:
does not activate Kafka auto-configuration:
KafkaTemplatecannot be autowired(
No beans of type 'KafkaTemplate' found)spring.kafka.*properties inapplication.ymlare ignoredUsing
spring-boot-starter-kafkaresolves the issue.However, this requirement is not mentioned in the Spring for Apache
Kafka documentation.
Context
While setting up Kafka in a Spring Boot 4.0.2 project, I followed the
official Spring for Apache Kafka documentation and added only the
spring-kafkadependency.This resulted in autowiring failures and missing property binding, which
was confusing because the documentation does not mention the need for
the Spring Boot starter.
I later discovered that Spring Initializr generates
spring-boot-starter-kafkafor Boot 4 projects, and adding it fixes theissue.
This can be particularly confusing for new users who rely on the Kafka
documentation directly rather than starting from Initializr.
A clarification in the documentation for Spring Boot 4 users would help
prevent this confusion.