From https://dzone.com/articles/bounty-spring-boot-and-postgresql-database
./mvnw clean package -DskipTests(cd ../postgres; docker compose up -d; ; docker compose ps)./mvnw spring-boot:runcurl -X GET http://localhost:8080/postgressApp/employeeList
curl -X GET http://localhost:8080/postgressApp/employeeList | jq .curl -X POST -H "Content-Type: application/json" \
-d \
'{ "employeeId": "2", "employeeName": "Joe", "employeeEmail": "[email protected]", "employeeAddress":"GB" }' \
http://localhost:8080/postgressApp/createEmpcurl -X GET http://localhost:8080/postgressApp/employeeList | jq .curl -X PUT -H "Content-Type: application/json" \
-d \
'{ "employeeId": "2", "employeeName": "Marie" }' \
http://localhost:8080/postgressApp/executeUpdateEmpcurl -X GET http://localhost:8080/postgressApp/employeeList | jq .curl -X DELETE -H "Content-Type: application/json" \
-d \
'{ "employeeId": "2"}' \
http://localhost:8080/postgressApp/deleteEmpByIdcurl -X GET http://localhost:8080/postgressApp/employeeList | jq .The main (server) class is src/main/java/com/sample/postgress/PostgressApplication.java.
The REST controller class is src/main/java/com/sample/postgress/controller/ApplicationController.java.
The Service class and interface are in src/main/java/com/sample/postgress/service.
The Entity class is src/main/java/com/sample/postgress/entity/Employee.java.
The Mapper class is src/main/java/com/sample/postgress/mapper/EmployeeRowMapper.java.
JDBC operations are in the class src/main/java/com/sample/postgress/dao/EmployeeDaoImpl.java.
Refactor the classes in order to change the type of employeeId in SERIAL. SERIAL is a pseudo-type to define auto-increment integer columns in tables.
The src/main/resources/schema.sql is:
CREATE TABLE employee
(
employeeId SERIAL,
employeeName VARCHAR(100) NOT NULL,
employeeAddress VARCHAR(100) DEFAULT NULL,
employeeEmail VARCHAR(100) DEFAULT NULL,
PRIMARY KEY (employeeId)
);