Spring Boot - 🧠 Guided Exercise: "Student Management System" (with Spring Boot + H2 + Validation + Error Handling) #193
akash-coded
started this conversation in
Tasks
Replies: 1 comment
-
|
PRASETHA N |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
🧠 Exercise: "Student Management System" (with Spring Boot + H2 + Validation + Error Handling)
🔧 Objective:
Build a Student Management API using Spring Boot, storing data in an H2 in-memory DB, with layered architecture, validation, and custom error handling.
📦 Requirements:
Spring Boot project (use start.spring.io) with these dependencies:
Port: Run on port
8081Database: Use H2 in-memory database. Console enabled at
/h2-console🗃️ Folder Structure
🧱 Step-by-Step Exercise Guide
1️⃣ Model Class: Student.java
✅ Learnings: Request validation annotations like
@NotBlank,@Email,@Min2️⃣ Repository Interface
3️⃣ Service Interface: StudentService.java
4️⃣ Service Implementation: StudentServiceImpl.java
5️⃣ Exception Class: StudentNotFoundException.java
6️⃣ Global Exception Handler
7️⃣ Controller: StudentController.java
8️⃣ application.properties
🧪 Test This With:
Sample JSON for
POST /api/students{ "name": "Sanya Mehta", "email": "sanya.mehta@example.com", "age": 22 }🚨 Expected Errors to Trigger:
age: 16→ should trigger validation/api/students/999→ custom not-found error🧩 Suggested Add-ons for Mastery
PUT /api/students/{id}to updateBeta Was this translation helpful? Give feedback.
All reactions