You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This project is a simple REST API built with Spring Boot to manage products (Create, Read, Update, Delete) using an in-memory H2 database.
Objective
To demonstrate proficiency in Java, Spring Boot (3.4.4), Spring Data JPA, REST API design, validation, error handling, and basic database interaction (H2).
Technologies Used
Java 21
Spring Boot 3.4.4
Spring Web
Spring Data JPA
H2 Database (In-Memory)
Maven
Lombok (for reduced boilerplate)
Spring Validation
Springdoc OpenAPI (for Swagger UI documentation)
Setup Instructions
Clone the repository:
git clone <your-github-repo-url>cd product-api
(Replace <your-github-repo-url> with the actual URL of your GitHub repository)
Build the project (optional, Spring Boot Maven plugin can run directly):
mvn clean package
Run the application:
Using Maven:
mvn sprgit ing-boot:run
Or run the ProductApiApplication.java main method directly from your IDE.
The application will start on http://localhost:8080.
Accessing H2 Database Console
The H2 in-memory database console is enabled and accessible at:
http://localhost:8080/h2-console
404 Not Found, {"timestamp": "2025-04-04T07:00:00.000+00:00", "status": 404, "error": "Not Found", "message": "Product with ID 99 not found", "path": "/products/99"}
PUT
/products/{id}
Update a product by ID
{"name": "Laptop Pro X", "price": 1349.00, "quantity": 10}
400 Bad Request, {"timestamp": "2025-04-04T07:00:00.000+00:00", "status": 400, "error": "Bad Request", "errors": {"price": "must be greater than 0"}}, 404 Not Found, {"timestamp": "...", "status": 404, "error": "Not Found", ...}
DELETE
/products/{id}
Delete a product by ID
(None)
204 No Content
404 Not Found, {"timestamp": "2025-04-04T07:00:00.000+00:00", "status": 404, "error": "Not Found", "message": "Product with ID 99 not found", "path": "/products/99"}