Install Java 21 Install Maven 3.9.6
DONT FORGET TO ADD YOUR ENVIRONMENT VARIABLE (JAVA_HOME, MAVEN_HOME)
mvn compile
mvn spring-boot:run
Navigate to: http://localhost:42069/swagger-ui/index.html
You are a developer working on an existing legacy project.
The project is a RESTful API that provides CRUD operations for a list of students.
The API is built using Spring Boot and uses in-memory storage to store the student data.
The project have tests for the API endpoints. All tests are passing.
You have been tasked with changing the in-memory storage to use a persistent storage mechanism.
-
Integrate H2 Database with Hibernate libraries for storing the student list
-
Update the existing add endpoint to save the student data to the database
-
Update the existing get endpoint to retrieve the student data from the database
-
Update the existing update endpoint to update the student data in the database
-
Update the existing delete endpoint to delete the student data from the database
-
Ensure that all existing tests are still passing after the changes
-
Ask copilot to help with commit message
-
Ask copilot to document the API endpoints in the source code
-
Do not change the existing tests, they should still pass after the changes with minimal modifications
-
Do not change the existing API endpoints
-
The existing add endpoint saves the student data to the database
-
The existing get endpoint retrieves the student data from the database
-
The existing update endpoint updates the student data in the database
-
The existing delete endpoint deletes the student data from the database
-
All existing tests are still passing after the changes
-
The commit message follows the convention:
feat: implement database integration using Hibernate
public class Student
{
private long id;
private String firstName;
private String lastName;
}
- URL:
/api/students - Method:
POST - Request Body:
{
"firstName": "John Doe",
"lastName": 25
}- Response Body:
{
"id": 1,
"firstName": "John Doe",
"lastName": 25
}-
URL:
/api/students/{id} -
Method:
GET -
Response Body:
{
"id": 1,
"firstName": "John Doe",
"lastName": 25
}- URL:
/api/students/{id} - Method:
PUT - Request Body:
{
"firstName": "John Doe",
"lastName": 25
}- Response Body:
{
"id": 1,
"firstName": "John Doe",
"lastName": 25
}- URL:
/api/students/{id} - Method:
DELETE