Access IBM Cloud Redis from a Spring Boot application

In this tutorial, learn how to access a Compose for Redis caching service on IBM Cloud from a Spring Boot application.

Redis is a popular open source in-memory database implementing a networked, in-memory key-value store.

Spring Boot is a popular library that offers an opinionated take of the Spring Framework that allows for the rapid development and deployment of production-ready Spring applications.


Create the Redis service

  1. Log in to IBM Cloud, and go to the Catalog.
  2. Under Database, select Compose for Redis.
  3. Click Create to create the service (the defaults should be fine).

When the service is fully deployed, which can take several minutes, you should see an overview screen similar to the following:

Redis configuration dashboard

Build and run the application

Download or clone this git repo from the Messaging with Redis Spring guide project:

git clone

Under the folder complete/src/main/resources/, create the file By default, Spring Boot will configure a Redis connection pointing to localhost:6379. To connect to the IBM Cloud Redis service, in, add the property spring.redis.url with the connection string to your Redis service. Using the above example, the file will look like this:


Under the complete folder, issue the following commands to build and run the application:

mvn clean install
java -jar target/gs-messaging-redis-0.1.0.jar

You should see the following output:

Redis console output


It’s that simple to create a Spring Boot application to access a Redis service on IBM Cloud! In my next tutorial, I’ll show you how to run the app on an IBM Cloud Kubernetes cluster using Kubernetes secrets to configure the service credentials.