An example repository for creating a Spring Boot CRUD application that connects to a PostgreSQL database.
Install and run Postgres through Docker:
docker run --name postgres \
-e POSTGRES_USER=dev \
-e POSTGRES_PASSWORD=password \
-e POSTGRES_DB=test_db \
-p 5432:5432 \
-d postgresVerify Docker is running:
docker psRun the application:
./gradlew bootRunYou can test this app using the cURL commands below. You may also prefer to use Postman for testing APIs which is more user-friendly.
curl -X POST http://localhost:8080/api/users \
-H "Content-Type: application/json" \
-d '{"name": "Jon","email": "jon@example.com", "age": 40}'curl -X GET http://localhost:8080/api/userscurl -X GET http://localhost:8080/api/users/1curl -X PUT http://localhost:8080/api/users/1 \
-H "Content-Type: application/json" \
-d '{"name": "JonUpdated", "email": "jon-updated@example.com", "age": 41}'curl -X DELETE http://localhost:8080/api/users/1