Simple REST API for creating, updating, listing and deleting tasks. Built with Spring Boot + JPA. Default runtime uses MySQL; tests use an in-memory H2 database.
- CRUD for tasks (
description,finished). - Validation with Jakarta Bean Validation (DTO) and explicit business rules in the entity.
- Global error handling for validation errors, bad input and missing records.
- OpenAPI docs via springdoc (Swagger UI at
/swagger-ui.html). testprofile using H2 (useful for running locally without MySQL as well).
- Java 17
- Spring Boot 3.3.5
- springdoc-openapi (Swagger UI)
- MySQL 8.4 (default), H2 (test profile)
- Maven Wrapper (
./mvnw)
- JDK 17+
- Docker (optional, for local MySQL)
- Start MySQL with Docker Compose:
docker compose up -d mysql- Compose file:
docker-compose.yaml
- Check DB config:
- MySQL runtime config:
src/main/resources/application.yaml
- MySQL runtime config:
- Run the app:
./mvnw spring-boot:run
- Base URL:
http://localhost:8080
- Swagger UI:
http://localhost:8080/swagger-ui.html(OpenAPI JSON athttp://localhost:8080/v3/api-docs)
Run the application with the test profile:
SPRING_PROFILES_ACTIVE=test ./mvnw spring-boot:runProfile config:
See src/main/resources/application.yaml:
spring.datasource.urlspring.datasource.usernamespring.datasource.passwordspring.jpa.hibernate.ddl-auto
From docker-compose.yaml:
- DB:
task_db - User/password:
task_user/task_pass - Root password:
task_pass
Endpoints use JSON and are available under /tasks:
- GET
/taskslist all tasks (sorted by description). - GET
/tasks/{id}get a single task. - POST
/taskscreate a task. - PATCH
/tasks/{id}update a task. - DELETE
/tasks/{id}delete a task.
Create (POST /tasks):
{ "description": "Write README" }Update (PATCH /tasks/{id}):
{ "description": "Reviewed docs", "finished": true }Note: the current implementation expects both description and finished on update (see controller/service at
src/main/java/com/thallesgarbelotti/task/controller/TaskController.java and
src/main/java/com/thallesgarbelotti/task/service/TaskService.java).
There is a dedicated file with ready-to-run commands:
Run tests:
./mvnw testTests use the test profile (H2) configured in
src/test/resources/application-test.yaml.
- Application code:
src/main/java/com/thallesgarbelotti/task - Runtime config:
src/main/resources/application.yaml - Tests:
src/test/java/com/thallesgarbelotti/task - Test profile config:
src/test/resources/application-test.yaml - Local MySQL:
docker-compose.yaml
SQL logging is enabled (see logging.level.org.hibernate.SQL in
src/main/resources/application.yaml). Uncomment
org.hibernate.orm.jdbc.bind to inspect parameter binding when needed.