Skip to content

TuTuAk/springboot-DB-Cloudfoundry-Georges2017

Repository files navigation

Spring Music

This is a simple application for demonstrating database services on Cloud Foundry with the Spring Framework and Spring Boot.

The application use Spring Java configuration and bean profiles to configure the application and the connection objects needed to use the persistence . It also uses the Spring Cloud Connectors library to inspect the environment when running on Cloud Foundry.

For this app, I use Springboot,SpringData, Gradle, Json, some J.Script, some Angular, Bootstrap, Cloudfoundry CLI.

Here is how the app is implemented:

On startup, Spring Boot's ApplicationContextInitializer will automatically add static web resources located within resources/albums.json. The java class AlbumRepositoryPopulator.java (package nl.cloudfoundry.musicdb.georges2017.repositories;) will make sure that Json is read into Object thanks to Jackson2ResourceReader and persist it in a database.

Talking about persistence, nowadays many different varieties of peristence technologies are being used to store data. By default, this SpringBoot app is implemented to persist data in-memory with the H2 DB but it also works with with mysql, postgres, mongodb, redis... . In my case I have overriden the default H2 DB by explicitly configuring MySQL db. The implementation can be seen here : package nl.cloudfoundry.musicdb.georges2017.config.SpringApplicationContextInitializer.java As you can see it: This app is prepared for using different databse providers such as Mongo, Mysql, Postgress and rediscloud.

The CRUD operations are done thanks to package org.springframework.data.repository.CrudRepository; so no need for boilerplate codes here.

Running the application on Cloud Foundry. This app can be run localy but I have opted to deploy it on the cloud(foundry). First you must prepare it for cloud deployment. The first thing to do is to run the gradle command $./gradlew assemble in order to generate the .jar or war file that will be read by the Cloud Foundry engine. After installing the 'cf' command-line interface for Cloud Foundry, you run the cf push command. The application will be pushed using settings in the provided manifest.yml. The manifest.yml is used cloudFoundry to locate the jar file located /spring-music-master/build/libs.

You can test the app by following the following cloudfoundry hyperlink: https://spring-music-georges2017-undeprecative-secretariat.cfapps.io/ (I have stopped the app to avoid billing from cloed foundry but i can start it upon your request if necessary )

Georges A. http://achillevanhoutte.blogspot.nl/

About

Deplying MysqlDB, JSOn, Springboot on cloudfoundry

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published