Accessing a Bluemix Redis Service from a Java Spring Boot Application

5 min read

Accessing a Bluemix Redis Service from a Java Spring Boot Application

In this post I’ll show how to access a Compose for Redis caching service on Bluemix from a Spring Boot application. Redis is a popular open-source in-memory database implementing a networked, in-memory key-value store. Spring is a popular open-source application framework and inversion of control container for Java.


You’ll need a Bluemix account, and you’ll need to have Maven and Java installed. It is assumed that you can build and run a basic Spring guide project.

Create the Redis Service

Login to Bluemix and go to the Catalog. Under Data & Analytics select Compose for Redis. Click Create to create the service (the only options are the service name and credential name – the defaults should be fine). When the service is fully deployed you should see an Overview screen similar to the screen below: Note the service’s host, port, and password which you can get from either the Connection String or the Command Line.

Create the Redis Service

Build and Run the Application

We’ll use the Messaging with Redis Spring guide project. Download the project, then build and run the complete project.

The project defaults to using a Redis server on localhost:6379. To use the Bluemix Redis service create a file src/main/resources/ with the host, port, and password properties from the Redis service page (above):



Rebuild and run the application by issuing the following commands:

$ mvn clean install<br>
$ java -jar target/gs-messaging-redis-0.1.0.jar<br>

You should see the following output:

You should see the following output:


It’s that simple to create a Spring Boot application to accessa Redis service on Bluemix! In my next post I’ll show you how to run the app on a Bluemix Kubernetes cluster using Kubernetes secrets to configure the service credentials.

Be the first to hear about news, product updates, and innovation from IBM Cloud