Spring REST Lab
Lab Title:
Building a RESTful Web Service using Spring Boot
Topic:
Spring Boot RESTful API
Learning Objectives:
● - Develop a basic RESTful API using Spring Boot.
● - Understand and use RESTful HTTP methods (GET, POST, PUT, DELETE).
● - Work with data using in-memory or file-based data structures.
● - Test REST APIs using Postman or any REST client.
Lab Tasks:
Use Case: Simple Product Catalog REST API
You will build a Spring Boot application that manages a product catalog. Each product has:
● - id: Integer
● - name: String
● - price: Double
● - category: String
Required Endpoints:
● - GET /products – Returns a list of all products.
● - GET /products/{id} – Returns a specific product by ID.
● - POST /products – Adds a new product. Accepts JSON in the request body.
● - PUT /products/{id} – Updates an existing product.
● - DELETE /products/{id} – Deletes the product with the specified ID.
Folder/File Structure:
spring-rest-lab/
├── src/
│ └── main/java/com/example/product/
│ ├── [Link]
│ ├── [Link]
│ └── [Link]
└── [Link]
Testing Instructions:
Use Postman, cURL, or a REST client to test each endpoint.
Example POST JSON:
{
"name": "Laptop",
"price": 799.99,
"category": "Electronics"
}
Submission Requirements:
● Submit a .zip file of the complete Spring Boot project.
● Include:
● - Screenshot of each API tested in Postman or REST client.
Grading Rubric (4%):
Criteria Marks
All endpoints implemented correctly 1.5
Correct data model and logic 0.5
Proper HTTP methods used 0.5
Working example/test screenshots 1.0
Code quality & folder structure 0.5
Total 4.0