Skip to content
Simple Redis & Spring Boot application used as a starter for demos and tests
Java HTML
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src/main
.gitignore
README.md
manifest.yml
pom.xml

README.md

Simple Redis Spring Boot Application

I used this application as a starter to test various features of Spring Boot & Redis.

Deploy and Run on Pivotal Cloud Foundry (PCF)

This project is ready to be deployed on PCF, the ./manifest.yml, and CloudConfig.java files will manage use the service binding from PCF to connect to Redis.

Log in to the Cloud Foundry environment:

$ cf login -a <url>

If you are not already in the proper organization you can create or select it using the following commands:

$ cf create-org redis-demos

$ cf create-space redis-upgrade -o redis-demos

$ cf target -o redis-demos -s redis-upgrade

You are now ready to create a new app, and bind it to a new Redis database.

Find the Redis plan that you want to use for your application:

$ cf marketplace 

OK

service          plans                                    description                                     broker
app-autoscaler   standard                                 Scales bound applications in response to load   app-autoscaler
p.mysql          db-small                                 Dedicated instances of MySQL                    dedicated-mysql-broker
redislabs        small-redis, medium-redis, large-redis   Enterprise-Grade Redis by Redis Labs            redislabs-broker

In my environment I am using the Redis Enterprise for PCF package. You can look at the various plans using: (in my case they are the default one)

$ cf marketplace -s redislabs

  Getting service plan information for service redislabs as admin...
  OK
  
  service plan   description                                                           free or paid
  small-redis    A small 1GB Redis, no replication or persistence.                     free
  medium-redis   A medium 5GB Redis, replication and data persistence.                 free
  large-redis    A large 10GB Redis with 2 shards, replication and data persistence.   free

Create a new Redis Service that will be use later by the application:

$ cf create-service redislabs  medium-redis my-medium-redis-instance

Creating service instance my-medium-redis-instance in org redis-demos / space redis-upgrade as admin...
OK

Build the project for Cloud Foundry

$  mvn clean package spring-boot:repackage

You have now multiple options to deploy and run the application, you can for example use the manifest.yml to bing the service during the deployment, but for learning purpose, let's do it using the cf command line.

This will be done in 3 steps:

  1. Push the application without starting it
  2. Bin the newly created RedisLabs service to the application
  3. Start the application
$ cf push --no-start
$ cf bind-service simple-pcf-spring-redis-app my-medium-redis-instance

You can look at the services and applications using the commands cf services and cf apps

Let's now start the application

$ cf start simple-pcf-spring-redis-app

You can find the URL to test the application using:

$ cf apps

Copy the URL and open your browser to go to the application running on PCF.

You can’t perform that action at this time.