Example application for spring-boot and postgresql
  • Java 91.1%
  • Shell 8.9%
Find a file
2021-12-15 09:28:53 +01:00
.vscode add infinispan 2021-12-15 09:10:17 +01:00
kustomize disable infinispan for now 2021-12-15 09:28:53 +01:00
src/main Initial 2021-12-11 14:59:52 +01:00
target add infinispan 2021-12-15 09:10:17 +01:00
mvnw Initial 2021-12-11 14:59:52 +01:00
mvnw.cmd Initial 2021-12-11 14:59:52 +01:00
pom.xml add infinispan 2021-12-15 09:10:17 +01:00
Readme.md small corrections and readme, ... 2021-12-11 15:40:14 +01:00
setenv.sh Initial 2021-12-11 14:59:52 +01:00

Spring Boot Accessing relational DB

This is a customized version of Accessing data with MySQL

  • ported to work with PostgreSQL (user is reserved, so we use my_user in pg)
  • make an OpenShift / Kubernetes Deployment

local start

  • Start local PostgreSQL with:
    • DB: db_example
    • User: springuser
    • PW: ThePassword
  • Source the config . ./setenv.sh
  • make clean mvn clean
  • run mvn spring-boot:run

You can use the REST Service in another Terminal Session with:

  • curl http://localhost:8080/demo/all to query your table
  • curl http://localhost:8080/demo/add -d name="My Famous new user" -d email="noone@no.address.com" to add records

deploy on OpenShift / OKD

  • go in your namespace: oc project mytestproject
  • Build the container: `kustomize build kustomize/openshift-build/ | oc apply -f -``
  • for the first time the build ist started automatic. After this you can restart the builds and show the output on commandline with oc start-build accessingdata -F
  • make a new instance dir with the content of ./kustomize/instancetemplate/ (for example ./kustomize/my_instance/)
  • edit the kustomization.yaml in my_instance (Look for namePrefix, storageclasses and sizes)
  • roll out using kustomize build my_instance | oc apply -f -

Test your work:

  • find the route of your service with oc get route

  • test it:

    export MYSVC=pp002-accessingdata-dev-mytestproject.apps.mysupercluster.net
    curl https://$MYSVC/demo/all
    curl https://$MYSVC/demo/add -d name="My Famous Name" -d email="this@one.does.not.exists"
    curl https://$MYSVC/demo/all