A Spring Boot–based Device Management microservice that provides REST APIs to create, update, fetch, and delete devices.
The application uses MySQL as the database, is containerized using Docker Compose, and the Docker image is built using Google Jib.
- CRUD REST APIs for device management
- Input validation using Jakarta Bean Validation
- Global exception handling with custom error responses
- MySQL database integration using Spring Data JPA
- Dockerized using Docker Compose
- Image built using Google Jib (no Dockerfile required)
- Swagger UI for API documentation
- Unit tests for Controller and Service layers
- Java 24
- Spring Boot 3.5.9
- Spring Data JPA
- Hibernate
- MySQL 8.0
- Docker & Docker Compose
- Google Jib
- JUnit 5 & Mockito
- Swagger (springdoc-openapi)
device/ ├── src/main/java/com/example/device │ ├── controller │ ├── service │ ├── service/impl │ ├── repository │ ├── entity │ ├── dto │ ├── exception │ └── constant ├── src/test/java/com/example/device │ ├── controller │ └── service ├── docker-compose.yml ├── pom.xml └── README.md
POST /devices/create
GET /devices/fetchsingledevice?name={name}&brand={brand}
GET /devices/alldevices
GET /devices/bybrand?brand={brand}
GET /devices/devicestate?state={AVAILABLE|IN_USE}
PUT /devices/updatedevice?name={name}&brand={brand}
DELETE /devices/delete?name={name}&brand={brand}
{ "name": "Samsung Mobile", "brand": "Samsung Brand", "deviceState": "AVAILABLE" }
The application is fully containerized using Docker Compose.
- MySQL database container
- Device Service Spring Boot container
docker compose up -d
mvn test
Includes:
- Controller tests using @WebMvcTest
- Service layer tests using Mockito
Once the application is running, access Swagger UI at:
http://localhost:8080/swagger-ui.html
The application image is built using Google Jib:
saurabh9705/device:v1
No Dockerfile is required.
The application uses environment variables for configuration:
SPRING_DATASOURCE_URL
SPRING_DATASOURCE_USERNAME
SPRING_DATASOURCE_PASSWORD
SPRING_PROFILES_ACTIVE
- Clear separation of Controller, Service, and Repository layers
- DTO-based API design
- Centralized exception handling
- Validation at API boundary
- Container-first microservice design
- Health-checked MySQL startup using Docker Compose
- Pagination and sorting
- Spring Security integration
- Flyway database migrations
- CI/CD using GitHub Actions
- Kubernetes deployment
Saurabh Singh
Java Backend Developer | Spring Boot | Microservices | Docker