Skip to content

Spring Kafka documentation does not mention spring-boot-starter-kafka requirement for Spring Boot 4 #4278

@RaidThabet

Description

@RaidThabet

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions