This project is a simple Spring Boot REST API connected to a PostgreSQL database.
It showcases a clean starter setup using:
- Spring Boot
- PostgreSQL
- Spring Data JPA
- Docker + docker-compose
- DBeaver / pgAdmin (optional for database UI)
- REST API for Employee CRUD
- Automatic table creation using Hibernate
- Local PostgreSQL setup
- Optional Docker-based PostgreSQL setup
- Production-ready folder structure
Download from:
https://www.postgresql.org/download/
During installation:
- Set username:
postgres - Set password: (choose your password)
- Install pgAdmin (optional)
Open pgAdmin → Query Tool:
CREATE DATABASE demo_db;This section explains how to run PostgreSQL locally using Docker with a simple docker-compose.yml setup.
This approach avoids manual installation and makes your database environment easy to reset or version.
Install:
Download: https://www.docker.com/products/docker-desktop/
Ensure Docker is running before executing commands.
Create a folder (example):
C:\postgres-docker
Inside it, create this file:
### **docker-compose.yml**
```yaml
version: '3.8'
services:
postgres:
image: postgres:15
container_name: postgres_local
restart: always
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: admin123
POSTGRES_DB: demo_db
ports:
- "5432:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
volumes:
postgres_data:
Run inside the folder containing docker-compose.yml:
docker compose up -dVerify the container:
docker psExpected:
postgres_local Up 0.0.0.0:5432->5432/tcp
Stop containers
docker compose downRemove containers & volume (wipe database)
docker compose down -vView logs
docker logs postgres_localRestart PostgreSQL
docker restart postgres_local