A modern RESTful Task Management API built with Spring Boot, Spring Data JPA, Hibernate, and an H2 In-Memory Database.
This project demonstrates enterprise Java backend development concepts including:
- REST API Design
- CRUD Operations
- DTO Pattern
- Validation
- Repository Pattern
- Service Layer Architecture
- Pagination
- Sorting
- Searching
- Filtering
- Custom JPQL Queries
- Exception Handling
- ResponseEntity
- Spring Boot Best Practices
- Features
- Tech Stack
- Project Structure
- Architecture
- Database
- Running the Project
- H2 Database Console
- API Documentation
- Request & Response Examples
- Pagination
- Sorting
- Searching
- Validation
- HTTP Status Codes
- Testing Endpoints
- Future Improvements
- Author
- Create Tasks
- Update Tasks
- Delete Tasks
- Get Task By ID
- Get All Tasks
- Pagination
- Sorting
- Search by Title
- Filter by Completion Status
- Search using Multiple Filters
- DTO Mapping
- Bean Validation
- H2 In-Memory Database
- Spring Data JPA
- Custom JPQL Queries
| Technology | Version |
|---|---|
| Java | 21+ |
| Spring Boot | 3.x |
| Spring Web | β |
| Spring Data JPA | β |
| Hibernate | β |
| H2 Database | β |
| Maven | β |
| Lombok | β |
| Jakarta Validation | β |
src
β
βββ controller
β TaskController.java
β
βββ service
β TaskService.java
β TaskServiceImpl.java
β
βββ repository
β TaskRepository.java
β
βββ entity
β Task.java
β
βββ dto
β TaskRequest.java
β TaskResponse.java
β
βββ exception
β
βββ TaskManagerApplication.java
Client
β
HTTP Request
β
TaskController
β
TaskService
β
TaskRepository
β
Hibernate
β
H2 Database
The application uses an H2 In-Memory Database.
spring.datasource.url=jdbc:h2:mem:taskdb
spring.datasource.username=sa
spring.datasource.password=passwordBecause it is an in-memory database, all data is deleted when the application stops.
git clone https://github.com/yourusername/task-manager.gitcd task-manager
mvn clean install
mvn spring-boot:run
Application starts on:
http://localhost:8080
Enable:
http://localhost:8080/h2-console
Credentials
| Field | Value |
|---|---|
| JDBC URL | jdbc:h2:mem:taskdb |
| Username | sa |
| Password | password |
Base URL
http://localhost:8080/api/v1/tasks
POST /api/v1/tasks
{
"title": "Learn Spring Boot",
"description": "Finish REST API section",
"completed": false
}201 Created
{
"id": 1,
"title": "Learn Spring Boot",
"description": "Finish REST API section",
"completed": false,
"createdAt": "2026-07-12T11:20:35"
}GET /api/v1/tasks
Supports
- Pagination
- Sorting
Example
GET /api/v1/tasks?page=0&size=5
Example
GET /api/v1/tasks?page=0&size=10&sortBy=createdAt&sortDir=DESC
Response
{
"tasks": [],
"currentPage": 0,
"totalItems": 15,
"totalPages": 2,
"hasNext": true,
"hasPrevious": false
}GET /api/v1/tasks/{id}
Example
GET /api/v1/tasks/1
Response
{
"id": 1,
"title": "Learn Spring Boot",
"description": "Finish REST API",
"completed": false,
"createdAt": "2026-07-12T10:00:00"
}POST /api/v1/tasks/{id}
Example
POST /api/v1/tasks/1
Request
{
"title": "Spring Boot Masterclass",
"description": "Updated Description",
"completed": true
}Response
{
"id": 1,
"title": "Spring Boot Masterclass",
"description": "Updated Description",
"completed": true,
"createdAt": "2026-07-12T10:00:00"
}DELETE /api/v1/tasks/{id}
Example
DELETE /api/v1/tasks/1
Response
200 OK
GET /api/v1/tasks/completed/{status}
Example
GET /api/v1/tasks/completed/true
or
GET /api/v1/tasks/completed/false
Response
[
{
"id": 3,
"title": "Deploy Project",
"completed": true
}
]GET /api/v1/tasks/search-by-title
Example
GET /api/v1/tasks/search-by-title?title=spring
Response
[
{
"id": 2,
"title": "Learn Spring Boot"
}
]GET /api/v1/tasks/search
Supports
- Title
- Completed
- Pagination
- Sorting
GET /api/v1/tasks/search?title=spring
GET /api/v1/tasks/search?completed=true
GET /api/v1/tasks/search?title=spring&completed=false
GET /api/v1/tasks/search?page=1&size=5
GET /api/v1/tasks/search?sortBy=title&sortDir=ASC
GET /api/v1/tasks/search?title=spring&completed=false&page=0&size=5&sortBy=createdAt&sortDir=DESC
Response
{
"tasks": [],
"currentPage": 0,
"totalItems": 7,
"totalPages": 2,
"hasNext": true,
"hasPrevious": false
}| Parameter | Description | Default |
|---|---|---|
| page | Current page | 0 |
| size | Page size | 10 |
| sortBy | Field used for sorting | createdAt |
| sortDir | ASC or DESC | DESC |
| title | Search title | Optional |
| completed | Filter completed tasks | Optional |
Current validation uses Jakarta Validation.
Example
@NotBlank
private String title;
@Size(max = 500)
private String description;Invalid requests return
400 Bad Request
| Code | Meaning |
|---|---|
| 200 | OK |
| 201 | Created |
| 400 | Bad Request |
| 404 | Not Found |
| 500 | Internal Server Error |
Import the endpoints below.
POST http://localhost:8080/api/v1/tasks
GET http://localhost:8080/api/v1/tasks
GET http://localhost:8080/api/v1/tasks/1
POST http://localhost:8080/api/v1/tasks/1
DELETE http://localhost:8080/api/v1/tasks/1
GET http://localhost:8080/api/v1/tasks/search?title=spring
GET http://localhost:8080/api/v1/tasks/search?completed=true
GET http://localhost:8080/api/v1/tasks/search?title=spring&completed=false
GET http://localhost:8080/api/v1/tasks/search-by-title?title=java
GET http://localhost:8080/api/v1/tasks/completed/true
SELECT * FROM TASKS;
SELECT * FROM TASKS
WHERE COMPLETED = TRUE;
SELECT * FROM TASKS
ORDER BY CREATED_AT DESC;- Swagger / OpenAPI Documentation
- Global Exception Handler
- JWT Authentication
- Spring Security
- PostgreSQL Support
- Docker
- Unit Tests
- Integration Tests
- Flyway Database Migration
- MapStruct
- Logging
- API Versioning
- Role-Based Authorization
- Java
- Spring Boot
- Spring Data JPA
- Hibernate
- SQL
- PostgreSQL
- REST APIs