diff --git a/spring-boot-samples/README.adoc b/spring-boot-samples/README.adoc
index 0e48ede4f86..c2d27ec1ad4 100644
--- a/spring-boot-samples/README.adoc
+++ b/spring-boot-samples/README.adoc
@@ -119,6 +119,9 @@ The following sample applications are provided:
| link:spring-boot-sample-junit-jupiter[spring-boot-sample-junit-jupiter]
| Demonstrates JUnit Jupiter-based testing
+| link:spring-boot-sample-kafka[spring-boot-sample-kafka]
+| consumer and producer using Apache Kafka
+
| link:spring-boot-sample-liquibase[spring-boot-sample-liquibase]
| Database migrations with Liquibase
@@ -230,6 +233,3 @@ The following sample applications are provided:
| link:spring-boot-sample-xml[spring-boot-sample-xml]
| Example show how Spring Boot can be mixed with traditional XML configuration (we
generally recommend using Java `@Configuration` whenever possible
-
-| link:spring-boot-sample-kafka[spring-boot-sample-kafka]
-| consumer and producer using Apache Kafka
diff --git a/spring-boot-samples/pom.xml b/spring-boot-samples/pom.xml
index 83792c9881b..e3a90ee1cc9 100644
--- a/spring-boot-samples/pom.xml
+++ b/spring-boot-samples/pom.xml
@@ -57,6 +57,7 @@
spring-boot-sample-jta-narayana
spring-boot-sample-jta-jndi
spring-boot-sample-junit-jupiter
+ spring-boot-sample-kafka
spring-boot-sample-liquibase
spring-boot-sample-logback
spring-boot-sample-oauth2-client
@@ -97,7 +98,6 @@
spring-boot-sample-websocket-undertow
spring-boot-sample-webservices
spring-boot-sample-xml
- spring-boot-sample-kafka
diff --git a/spring-boot-samples/spring-boot-sample-kafka/pom.xml b/spring-boot-samples/spring-boot-sample-kafka/pom.xml
index 901631faa6e..e0d3ca27171 100644
--- a/spring-boot-samples/spring-boot-sample-kafka/pom.xml
+++ b/spring-boot-samples/spring-boot-sample-kafka/pom.xml
@@ -20,16 +20,12 @@
org.springframework.boot
- spring-boot-starter
+ spring-boot-starter-json
org.springframework.kafka
spring-kafka
-
- org.springframework.boot
- spring-boot-starter-json
-
org.springframework.boot
@@ -39,6 +35,7 @@
org.springframework.kafka
spring-kafka-test
+ test
diff --git a/spring-boot-samples/spring-boot-sample-kafka/src/main/java/sample/kafka/Consumer.java b/spring-boot-samples/spring-boot-sample-kafka/src/main/java/sample/kafka/Consumer.java
index 4e7e2a8b3d3..a18227b40a4 100644
--- a/spring-boot-samples/spring-boot-sample-kafka/src/main/java/sample/kafka/Consumer.java
+++ b/spring-boot-samples/spring-boot-sample-kafka/src/main/java/sample/kafka/Consumer.java
@@ -19,10 +19,11 @@ import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;
@Component
-public class Consumer {
+class Consumer {
- @KafkaListener(topics = "myTopic")
+ @KafkaListener(topics = "testTopic")
public void processMessage(SampleMessage message) {
- System.out.println("consumer has received message : [" + message + "]");
+ System.out.println("Received sample message [" + message + "]");
}
+
}
\ No newline at end of file
diff --git a/spring-boot-samples/spring-boot-sample-kafka/src/main/java/sample/kafka/Producer.java b/spring-boot-samples/spring-boot-sample-kafka/src/main/java/sample/kafka/Producer.java
index 89c50e3533a..3297bb4780c 100644
--- a/spring-boot-samples/spring-boot-sample-kafka/src/main/java/sample/kafka/Producer.java
+++ b/spring-boot-samples/spring-boot-sample-kafka/src/main/java/sample/kafka/Producer.java
@@ -15,18 +15,21 @@
*/
package sample.kafka;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.stereotype.Component;
@Component
public class Producer {
- @Autowired
- private KafkaTemplate kafkaTemplate;
+ private final KafkaTemplate