1. Download this repository as .zip
or clone the repository by following command
git clone https://github.com/root113/Spring-Boot-L1.git
2. You need to have PostgreSQL
and Docker
installed on your system
- To install PostgreSQL follow the instructions on these links below depending on your OS:
- To install Docker follow the instructions on these links below depending on your OS:
3. Start a postgres instance and follow the insturctions. (You can name credentials at your will but remember that you have to change relevant parts inside source code according to it)
- Init:
docker run --name postgres-spring -e POSTGRES_PASSWORD=1234 -d -p 5432:5432 postgres:alpine
- Check new container's id:
docker ps
- Bash into the container:
docker exec -it container_id bin/bash
4. Switch to user postgres
psql -U postgres
5. Database setup
- Create database and connect:
CREATE DATABASE demodb;
\c demodb
- If you are not using IntelliJ Idea Ultimate Edition, the sql script that is writtien inside
demo/src/main/resources/db/migration/v1__PersonTable.sql
will not work. Thus, you have to create the table manually. If not, skip this step.CREATE TABLE person (id UUID NOT NULL PRIMARY KEY, name VARCHAR(100) NOT NULL);
- Create extension for UUID generator:
CREATE EXTENSION "uuid-ossp";
- Insert your test datas:
INSERT INTO person (id, name) VALUES (uuid_generate_v4(), 'Example Name');
Postman is recommended but not necessary. You can use any browser with below command to list the test datas (Default port is set to 8080. If it is already in use, kill which process uses it or try changing the port to something different.)
localhost:8080/api/v1/person