You can run the app with embedded DB using:
mvn spring-boot:run
You can also run the app with PostgreSQL:
docker compose up
You can run the app with PostgreSQL on minikube using:
kubectl apply -f k8s/db-stateful-set.yaml
docker build -t hello-spring-data-jpa .
minikube image load hello-spring-data-jpa:latest
kubectl apply -f k8s/app-deployment.yaml
kubectl port-forward deployment/hello-spring-data-jpa-app-deployment 8080:8080 &
You can test the running app using curl:
curl -X POST -H "Content-Type:application/json" -d '{"title":"DB config", "text":"Switch to PostreSQL"}' http://localhost:8080/todos
curl -X POST -H "Content-Type:application/json" -d '{"title":"Improve REST API", "text":"Use Srping HATEOAS"}' http://localhost:8080/todos
curl -X GET http://localhost:8080/todos
curl -X GET http://localhost:8080/todos/<id>
curl -X PUT -H "Content-Type:application/json" -d '{"title":"Improve REST API", "text":"Use Spring HATEOAS"}' http://localhost:8080/todos/<id>