An example project that demonstrates a Spring microservice that performs CRUD operations on Postgres relational database running on Docker.
Create and start postgres container:
docker run --name postgres-spring -e POSTGRES_PASSWORD=password -d -p 5432:5432 postgres:alpine
For testing and DB configurations, connect to the container`s shell:
docker exec -it <container_id> bin/bash
Start Postgres CLI:
psql -U postgres
Create the database:
CREATE DATABASE demodb;
Connect:
\c demodb
Add the UUID creation extension:
CREATE EXTENSION "uuid-ossp";