Get Started Free
course: Spring Framework and Apache Kafka®

Hands On: Introduction to Spring Boot for Apache Kafka

6 min
Viktor Gamov

Viktor Gamov

Developer Advocate (Presenter)

Hands On: Introduction to Spring Boot for Apache Kafka

This exercise sets up a new Spring Boot project with Spring for Apache Kafka and connects it with Confluent Cloud.

Set Up and Download a Project from Spring Initializr

  1. Go to and add a new project, selecting Gradle, Java, and the default version of Spring Boot.

  2. Add your project’s metadata as Group: ”io.confluent.developer,” Artifact: “spring-ccloud,” Description: “Demo project for Spring Boot with Confluent Cloud,” and Package Name: “io.confluent.developer.spring.”

    Select Jar packaging and Java 11.

  3. Click the Add Dependencies button and add Spring for Apache Kafka, Spring for Apache Kafka Streams, Cloud Stream, Lombok, and Spring Reactive Web.


  1. Click Generate to download a ZIP archive. In your terminal, unzip the file:


    Then open the spring-ccloud directory in your IDE.

Set Up Confluent Cloud

  1. Now, open a browser and navigate to Confluent Cloud (if you don’t have an account, you can sign up for a free trial (details) and use the promo code SPRING101 for an additional $25 of free usage).

  2. In the default environment, go to Add Cluster, then create a Basic cluster, and click Begin configuration.


  1. Select Google Cloud, a close region, and single zone availability (the associated costs are listed, but the free usage will be more than enough for this course). Name your cluster and click Launch cluster. Keep in mind that you should delete your cluster when you are finished with it to avoid extra costs. Instructions for deleting are given at the end of Hands On: Confluent Cloud Schema Registry.


  1. To get your Spring Boot config, go to Clients on the left menu and select Spring Boot. Underneath the config, select Create Kafka cluster API key & secret. Add the description spring kafka lesson, select I have saved my API key and secret and am ready to continue, and click Continue to populate your credentials.


Add Confluent Cloud Credentials to Spring

  1. Copy the “#Kafka” section of your config, click Done, and then go back to your IDE with Spring.

    # Kafka required username='{{ CLUSTER_API_KEY }}' password='{{ CLUSTER_API_SECRET }}';
  2. Under src/main/resources/, paste the config.

Use the promo code SPRING101 to get $25 of free Confluent Cloud usage

Be the first to get updates and new content

We will only share developer content and updates, including notifications when new content is added. We will never send you sales emails. 🙂 By subscribing, you understand we will process your personal information in accordance with our Privacy Statement.