A Spring Boot REST API for managing tasks with full CRUD operations.
| HTTP Method | Endpoint | Description |
|---|---|---|
| GET | /api/tasks |
Retrieve all tasks |
| POST | /api/tasks |
Create a new task |
| PUT | /api/tasks/{id} |
Update an existing task by ID |
| DELETE | /api/tasks/{id} |
Delete a task by ID |
- Database: MySQL
- Database Name:
taskdb - Integration:
- Used Spring Data JPA to interact with MySQL.
- The entity class
Taskis mapped to a database table. - Database connection configured in
application.propertieswith JDBC URL, username, and password. - Hibernate automatically manages schema updates with
spring.jpa.hibernate.ddl-auto=update.
- Java 21 or above installed
- Maven installed
- MySQL server running
-
Create the database (if not already done):
CREATE DATABASE taskdb;
-
Configure your MySQL credentials in
src/main/resources/application.properties:spring.datasource.url=jdbc:mysql://localhost:3306/taskdb spring.datasource.username=root spring.datasource.password=system spring.jpa.hibernate.ddl-auto=update
-
Build and run the Spring Boot app:
./mvnw spring-boot:run
-
Server will start on:
http://localhost:9091(or the configured port)
You can use tools like Postman, curl, or any HTTP client.
-
Create a Task (POST
/api/tasks){ "title": "Finish API Server", "description": "Build and test Spring Boot API project", "completed": false } -
Get All Tasks (GET
/api/tasks)Response:
[ { "id": 1, "title": "Finish API Server", "description": "Build and test Spring Boot API project", "completed": false } ] -
Update a Task (PUT
/api/tasks/{id}){ "title": "Finish API Server - Updated", "description": "Updated project backend", "completed": true } -
Delete a Task (DELETE
/api/tasks/{id})
- JUnit 5 – For writing unit and integration tests
- Mockito – For mocking dependencies
- MockMvc – For simulating HTTP requests in API tests
- JaCoCo – For generating code coverage reports
To run all tests and generate the code coverage report:
./mvnw clean testor on Windows:
mvnw.cmd clean test📂 After running, the coverage report can be found at:
target/site/jacoco/index.html
🧪 All test classes are located in: src/test/java/com/example/taskmanager/
