Giter Site home page Giter Site logo

cf-springboot-psql-workshop's Introduction

cf-springboot-psql-workshop

Workshop project that guides users through building a REST API using Spring Boot. The app makes use of a Postgresql database to store and retrieve todo items. Additionally the app is intended to be deployed on Cloud Foundry.

How to use this project

On the main branch, the project is completely empty. Go through the steps mentioned below. You will find solutions for each step on the respective branch (step-n-solution)

Prerequisites

  • Docker installed
  • Java SDK installed
  • Tool for making requests (postman, insomnia, curl)

step 1

  • Create a new project skeleton using spring initializr (https://start.spring.io)
  • Find out which dependencies you will need.

Hints:

  • Don't use Cloud Connector
  • Use Maven as package manager
  • If you add the persistence dependencies now already, spring will assume that there is a db to that the app can create a connection to. Maybe it is clever to keep the dependencies in mind but not add them from the beginning.

step 2

  • Import project into your IDE
  • Run the application

step 3

  • Create a REST Endpoint (hello world)
  • Run the app and test the endpoint

Hints:

  • Don't use the @Controller annotation

step 4

  • Create an entity that holds a todo entry
  • What do you need additionally for the persistence layer? Create that component

Hint:

  • Now it is time to add the persistence dependencies

step 5

  • Run a postgresql server locally. (docker run -p5432:5432 --name postgres -e POSTGRES_PASSWORD=mysecretpassword -d postgres)
  • Configure the connection to your local postgres server.
  • Run your application, it will tell you if the connection to postgres was successful.

Hint:

  • Use application.properties for the connection details

step 6

  • Create REST endpoints for read and write operations
  • Connect everything so that API calls actually make use of postgres
  • Test your endpoints

step 7

Requirement: App should run locally and in the cloud

  • Create a Cloud Foundry manifest.
  • How can you configure the db connection for running in Cloud Foundry? Create the configuration
  • Create the needed resources on Cloud Foundry.
  • Run your app on Cloud Foundry
  • Test your application

Hint:

step 8 - bonus

Try to change the application so that you don't need the explicit configuration via properties file(s).

cf-springboot-psql-workshop's People

Contributors

iamnoah1 avatar

Watchers

 avatar  avatar  avatar

Forkers

dataone

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.