This project is a modern web application developed with Spring Boot and Spring MVC. Its purpose is to manage a collection of cars in a dealership's system. The application uses HTML pages (Thymeleaf/JTE) for the user interface, where users can perform CRUD operations (Create, Read, Update, Delete).
The application supports the following functionality:
- List all cars: An overview page displaying all cars in stock.
- Create new cars: A form to add a new car with validation.
- Update cars: The ability to edit information for an existing car.
- Delete cars: A function to remove a car from the system.
- Validation: Clear error messages in forms if data is missing or incorrect.
Class: Car
Data is persisted in the database via JPA. A car entity includes at least:
- ID: (Auto-generated)
- Brand: The car's manufacturer (e.g., Volvo)
- Model: The car's model name (e.g., V60)
- Description: A short text about the car
- Year: The car's manufacturing year
- Registration Number: (Domain-specific attribute)
The application is divided into the following layers for a clean structure:
- Repository:
CarRepository(ExtendsListCrudRepository, handles database communication). - Service:
CarService(Handles business logic and calls the Repository). - Controller:
CarController(Handles HTTP requests and returns HTML views).
To separate the database model from what is displayed or submitted in forms, DTOs are used:
CreateCarDTO: Used in the form when creating a car.UpdateCarDTO: Used in the form when updating a car.CarDTO: Used to display car data in lists.- Mapper: A class that converts data between the
Car(Entity) and the DTOs.
- Framework: Spring Boot, Spring MVC
- Database: Spring Data JPA (with e.g., H2 or MySQL)
- Validation: Jakarta Bean Validation (Hibernate Validator)
- Views: HTML with Thymeleaf (or JTE)
- Testing: JUnit, Mockito
- Create
Carentity andCarRepository. - Create Service layer and Mapper.
- Implement Controller and HTML views (List, Create, Update, Delete).
- Add validation and error handling.
- Write unit tests.