This project is a beginner-friendly, production-style Spring Boot REST API for task management. It is designed for a 1-day hands-on workshop where students learn:
- how a Spring Boot project is structured
- how REST APIs are created in real projects
- how profiles (
dev,prod) change application behavior - how to handle errors cleanly (
400,404) - how in-memory data works before using a real database
Install these before running:
- Java 17 (required)
- IntelliJ IDEA Community or Ultimate
- Internet connection (first run downloads Maven dependencies)
Verify Java:
java -versionYou should see Java 17 in output.
- Open IntelliJ IDEA.
- Click Open.
- Select the folder
springboot-workshop. - IntelliJ will detect
pom.xmland import as a Maven project. - Wait for indexing and Maven sync to complete.
- Open TaskApiApplication.java.
- Click the green Run icon next to
main()to run from IDE.
If IntelliJ asks for JDK, choose Java 17.
This project includes Maven Wrapper, so system Maven is not needed.
.\mvnw.cmd spring-boot:run./mvnw spring-boot:runDefault active profile is dev, and app starts on port 8080.
.\mvnw.cmd spring-boot:run "-Dspring-boot.run.profiles=dev".\mvnw.cmd spring-boot:run "-Dspring-boot.run.profiles=prod"Notes:
devprofile: port8080, modedevelopment, DEBUG logging.prodprofile: port80, modeproduction, WARN logging.- On some systems, port
80may require admin/root permission.
Base URL (dev): http://localhost:8080
curl -s http://localhost:8080/tasksExpected response:
[
{"id":1,"title":"Set up Spring Boot project","status":"OPEN"},
{"id":2,"title":"Build Task REST API","status":"IN_PROGRESS"},
{"id":3,"title":"Test endpoints with curl","status":"DONE"}
]curl -s -X POST http://localhost:8080/tasks \
-H "Content-Type: application/json" \
-d "{\"title\":\"Write workshop notes\",\"status\":\"OPEN\"}"Expected response (201 Created):
{"id":4,"title":"Write workshop notes","status":"OPEN"}curl -s http://localhost:8080/tasks/2Expected response:
{"id":2,"title":"Build Task REST API","status":"IN_PROGRESS"}curl -s -X PUT http://localhost:8080/tasks/2 \
-H "Content-Type: application/json" \
-d "{\"title\":\"Build Task REST API - updated\",\"status\":\"DONE\"}"Expected response:
{"id":2,"title":"Build Task REST API - updated","status":"DONE"}curl -i -X DELETE http://localhost:8080/tasks/2Expected response:
- HTTP status:
204 No Content - Body: empty
curl -s http://localhost:8080/tasks/infoExpected response in dev:
{"appVersion":"1.0.0","appMode":"development","port":"8080"}Expected response in prod:
{"appVersion":"1.0.0","appMode":"production","port":"80"}curl -s http://localhost:8080/tasks/999Expected response:
{"status":404,"error":"Not Found","message":"Task not found with id: 999"}curl -s -X POST http://localhost:8080/tasks \
-H "Content-Type: application/json" \
-d "{\"title\":\"Bad status test\",\"status\":\"PENDING\"}"Expected response:
{"status":400,"error":"Bad Request","message":"Status must be one of: OPEN, IN_PROGRESS, DONE."}curl -s -X POST http://localhost:8080/tasks \
-H "Content-Type: application/json" \
-d "{\"title\":\" \",\"status\":\"OPEN\"}"Expected response:
{"status":400,"error":"Bad Request","message":"Title is required and cannot be blank."}- TaskApiApplication.java
- Main entry point (
main()), starts Spring Boot. - Contains startup data seeder (
CommandLineRunner) that inserts 3 sample tasks.
- Main entry point (
- Task.java
- Data model (POJO) with fields
id,title,status.
- Data model (POJO) with fields
- TaskService.java
- In-memory storage using
HashMap. - ID generation using
AtomicLong. - CRUD-style methods used by controller.
- In-memory storage using
- TaskController.java
- REST endpoints (
GET,POST,PUT,DELETE,/info). - Input validation and HTTP error handling.
- REST endpoints (
- application.yml
- Common/base config (name, default profile, app metadata).
- application-dev.yml
- Dev profile config (
8080, development mode, DEBUG logs).
- Dev profile config (
- application-prod.yml
- Prod profile config (
80, production mode, WARN logs).
- Prod profile config (
- pom.xml
- Maven build configuration and dependencies.
mvnw is not recognized- Windows: use
.\mvnw.cmd(notmvnw).
- Windows: use
- Port already in use (8080 or 80)
- Close the app using that port, or run with another port:
.\mvnw.cmd spring-boot:run "-Dspring-boot.run.arguments=--server.port=8081"
- Java version mismatch
- Ensure
java -versionshows 17.
- Ensure
403/permission deniedon port 80 in prod- Run terminal as Administrator, or temporarily override port while keeping prod profile.
curlcommand issues in PowerShell- Use
curl.exeexplicitly instead ofcurlalias.
- Use
- Add a new field
descriptiontoTaskand return it in all APIs. - Add endpoint
GET /tasks/status/{status}to filter by status. - Add validation rule: title must be at least 5 characters.
- Add endpoint
PATCH /tasks/{id}/statusto update only status. - Enforce
app.max-tasksstrictly and return a custom error when limit is reached. - Add a simple unit test for
TaskService(optional advanced exercise).
- Run app and hit
GET /tasks. - Explain model, service, controller layers.
- Walk through create/update/delete APIs.
- Show error handling (
400,404) live. - Switch profiles and call
/tasks/info. - Give exercises for pair practice.
This project now also includes a browser-based learning UI served directly by Spring Boot.
- Start the application:
- PowerShell:
.\mvnw.cmd spring-boot:run
- PowerShell:
- Open browser:
http://localhost:8080
- Learn key concepts from visual cards (
Controller,Service,Model,Profiles). - Use the API Playground to call:
GET /tasksPOST /tasksGET /tasks/{id}PUT /tasks/{id}DELETE /tasks/{id}GET /tasks/info
- Use the Live Task Board to move tasks across statuses.
- Complete Challenge Mode:
- create one task
- move one task
- trigger
404 - trigger
400
The web app now includes built-in student assessment and reporting.
- Student Session capture:
- Roll number (required)
- Name (optional)
- Batch/Section (optional)
- Quiz Arena:
- 12 multiple-choice questions on Spring Boot fundamentals
- Instant feedback on each question
- Auto score + percentage + grade (
A+toF)
- Grade Report:
- JSON report download
- TXT report download
- Includes student details, quiz score, challenge progress, API metrics
- API Inspector:
- Timeline of API calls with method, endpoint, status, and latency
- Click any call to inspect full request and response
- Observation prompts:
- Students are guided on what to observe while interacting with APIs
- Ask each student to enter roll number in Student Session.
- Let students complete API challenge tasks.
- Ask students to inspect at least one API call from API Inspector.
- Run the 12-question quiz.
- Download and collect grade reports (
JSONorTXT).