Skip to content
Kafka Is Fun

Getting Started · Beginner · Topic 2 of 5

application.yml Configuration

Core Spring Kafka properties. Spring Boot passes them to the Kafka clients and auto-configures KafkaTemplate and the listener containers from them. Kafka's own client settings go under properties.

application.ymlyaml
spring:
  kafka:
    bootstrap-servers: localhost:9092

    producer:
      key-serializer: org.apache.kafka.common.serialization.StringSerializer
      # Spring Kafka 4.x name; earlier versions call it JsonSerializer
      value-serializer: org.springframework.kafka.support.serializer.JacksonJsonSerializer
      acks: all                       # the Kafka 4.2 default, written out for clarity
      properties:
        enable.idempotence: true      # the default
        max.in.flight.requests.per.connection: 5   # the default; idempotence needs <= 5
        retries: 2147483647           # the default, bounded by delivery.timeout.ms (120000 by default)

    consumer:
      group-id: my-service
      auto-offset-reset: earliest
      key-deserializer: org.apache.kafka.common.serialization.StringDeserializer
      value-deserializer: org.springframework.kafka.support.serializer.JacksonJsonDeserializer
      properties:
        spring.json.trusted.packages: "com.example.*"   # packages the JSON deserializer may instantiate

    listener:
      ack-mode: BATCH                 # the container default
      concurrency: 3

Sources

Checked against Spring for Apache Kafka 4.1.1, Spring Boot 4.1.1 and Kafka 4.2 documentation on 11 October 2026. Draft: not yet reviewed by a Kafka specialist, and releases move on, so confirm against the current documentation before you act on it.