This is a simple Spring Boot based app to demonstrate different ways of connecting to a service or a datastore when deploying to Cloud Foundry.
Let Java Buildpack Autoreconfiguration handle it
The simplest approach is to do nothing and let Cloud Foundry’s Java Buildpack handle the details. Cloud Foundry’s Java Buildpack injects a library called the Java Buildpack Auto Reconfiguration into the runtime deployable which reconfigures the service connectivity appropriately.
Use Java Environment properties
Spring Boot exposes the VCAP_SERVICES properties which is in the form of a JSON into a more consumable format - as simple environment properties. These properties can be used for configuring the connectivity to the service
Use Spring Cloud Connector
Spring Cloud Connector provides the most advanced configuration for enabling connectivity to an external service.
Any of the versions of the application can be brought up by the following steps:
Installing and deploying a MYSql on Mac OSX
brew install mysql mysql.server start mysql -u root CREATE USER 'springpong'@'localhost' IDENTIFIED BY 'springpong'; CREATE DATABASE pong_matcher_spring_development; GRANT ALL ON pong_matcher_spring_development.* TO 'springpong'@'localhost';
Start the application
Check if the application has started up
Try the endpoint available here - http://localhost:8080/courses