1. Clone the repository
git clone https://gitlab.com/hendisantika/spring-boot-postgresql.git
2. Configure PostgreSQL
First, create a database named postgres_demo. Then, open src/main/resources/application.properties file and change the spring datasource username and password as per your PostgreSQL installation.
3. Run the app
Type the following command from the root directory of the project to run it -
mvn clean spring-boot:run
Alternatively, you can package the application in the form of a JAR file and then run it like so -
mvn clean package
java -jar target/spring-boot-postgresql-0.0.1-SNAPSHOT.jar
The application will start on the default port 8080.
The following screenshots show you how to test the APIs using Postman.
1. Create Question POST /questions
2. Get paginated Questions GET /questions?page=0&size=2&sort=createdAt,desc
3. Create Answer POST /questions/{questionId}/answers
4. Get all answers of a Question GET /questions/{questionId}/answers