Spring Boot extends Spring with convention-over-configuration defaults, reducing the infrastructure needed to build Kafka applications. It can also provide a built-in web server. section 12.2 section 12.3
A Spring Boot Kafka application typically combines:
- @SpringBootApplication identifies the application and configuration class, while application.properties supplies values injected with @Value. section 12.2
- NewTopic beans declare the Kafka topics required by the application, including partition and replication settings. section 12.2
- @EnableKafka activates Spring Kafka support; @EnableKafkaStreams activates Spring Boot support for Kafka Streams applications. section 12.3 section 12.4
- Kafka Streams applications can use the default lifecycle management or retain more control by wiring Spring dependency injection around an explicit KafkaStreams instance. section 12.3 section 12.4
Loan application processing
A loan website publishes applications to an input topic. An underwriting application processes them and sends accepted, rejected, and randomly selected quality-assurance results to separate topics. A Spring Boot configuration class can inject topic properties, declare NewTopic beans, and start without a web server when configured with WebApplicationType.NONE. The same application can later become a Kafka Streams topology that aggregates approvals and rejections, with the default web server supporting interactive-query endpoints. section 12.2 section 12.3
Listing 12.4 Basic configuration, which is substantially less with Spring Boot
@Configuration
public class LoanApplicationProcessingApplication {
@Value("${application.group}")
private String groupId;
@Value("${loan.app.input.topic}") #1
private String loanAppInputTopic;
// Other configurations left out for clarity
@Bean
public NewTopic loanAppInputTopic() { #2
return new NewTopic(loanAppInputTopic,
partitions,
replicationFactor);
}
// Other NewTopic beans left out for clarity
Inspect the reduced configuration pattern: injected topic properties and NewTopic beans replace much of the surrounding Kafka infrastructure code. section 12.2



