kafka-configuration

Configures Spring Boot Kafka starter properties and generates KafkaTemplate and listener factory beans.

Updated May 4, 2026
One-click install
npx skills add https://github.com/studenkov/FinanceTracker --skill kafka-configuration-studenkov
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: kafka-configuration
Source: https://github.com/studenkov/FinanceTracker/tree/main/.agents/skills/kafka-configuration
Command: npx skills add https://github.com/studenkov/FinanceTracker --skill kafka-configuration-studenkov

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Setting up Kafka in a Spring Boot project requires correctly wiring serializer/deserializer classes, consumer groups, trusted packages, and listener container factories across properties files and configuration classes, which is error-prone and version-sensitive. ## Core Features & Use Cases - Property-based configuration: Writes all six spring.kafka.* keys (bootstrap servers, consumer group, serializers, deserializers) into application.properties or application.yml. - Configuration class generation: Generates a KafkaConfiguration class with ProducerFactory, KafkaTemplate, ConsumerFactory, and ConcurrentKafkaListenerContainerFactory beans for Java or Kotlin across Spring Boot 3.0 through 4.x. - Dependency and module handling: Detects or adds the spring-boot-starter-kafka dependency, selects the correct module in multi-module projects, and reuses existing Kafka beans when present. - Use Case: Ask to configure Kafka for publishing OrderEvent messages with consumer group orders, and the skill writes the properties, adds the dependency, and generates typed beans with correct JSON trusted packages. ## Quick Start Configure Kafka in my Spring Boot project to produce and consume OrderEvent messages with consumer group orders.

Frequently Asked Questions about kafka-configuration

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I configure Kafka in a Spring Boot application?

Set spring.kafka.bootstrap-servers and spring.kafka.consumer.group-id in application.properties or application.yml, plus producer key/value serializers and consumer key/value deserializers. Spring Boot's KafkaAutoConfiguration then creates the ProducerFactory, ConsumerFactory, KafkaTemplate, and listener container factory beans.

How to create a KafkaTemplate and KafkaListener container factory in Spring?

Define beans for DefaultKafkaProducerFactory, KafkaTemplate, DefaultKafkaConsumerFactory, and ConcurrentKafkaListenerContainerFactory in a @Configuration class. The listener factory must be named kafkaListenerContainerFactory so the autoconfiguration backs off and @KafkaListener uses it by default.

Which Kafka serializer should I use for JSON POJO messages in Spring Boot?

Use org.springframework.kafka.support.serializer.JsonSerializer and JsonDeserializer on Spring Boot 3.x, or JacksonJsonSerializer and JacksonJsonDeserializer on Spring Boot 4.x. You must also set spring.json.trusted.packages to the POJO's package on the consumer side.

Does Spring Boot 4 change Kafka configuration compared to Boot 3?

Yes. Spring Boot 4 moves KafkaProperties to the org.springframework.boot.kafka.autoconfigure package and replaces JsonSerializer/JsonDeserializer with JacksonJson variants. Boot 3.2+ also passes SslBundles to buildProducerProperties and buildConsumerProperties.

Why does Kafka JsonDeserializer fail with 'class is not in the trusted packages'?

JsonDeserializer rejects POJO types whose packages are not listed in spring.json.trusted.packages. Set it to a comma-separated list of the consumer-side POJO packages, never a wildcard, and add spring.json.key.default.type or value.default.type for POJO keys or values.