Section 15 · Stage 4: Build Applications
Spring Framework & Spring Boot
Dependency injection, Spring Boot applications, REST controllers, validation, error handling and configuration.
What you will be able to do
- Explain inversion of control and dependency injection and use them in Spring
- Create a Spring Boot application and understand what auto-configuration does
- Build REST controllers with request validation and consistent error responses
- Organise code into controller, service and repository layers
- Configure an application with properties, profiles and logging
- Turn ShopLite into a Spring Boot REST API documented with OpenAPI
What you will learn
15.1Why Spring?7 lessons
The problems Spring solves, how the Spring family fits together, and your first Spring Boot 4.1 project.
15.2Dependency Injection & Beans8 lessons
Let Spring create your objects and wire them together, and control how many there are and when they start and stop.
- Beans and the application context40 min
- @Component, @Service, @Repository and @Controller40 min
- Constructor injection and why to prefer it45 min
- @Configuration and @Bean40 min
- Several implementations: @Qualifier and @Primary45 min
- Bean scopes and lifecycle callbacks45 min
- Practice: dependency injection and beans50 min
- Mini project: ShopLite cart pricing with beans60 min
15.3How Spring Boot Works8 lessons
What happens when a Spring Boot application starts: starters, auto-configuration, scanning, the embedded server and the startup log.
15.4Building REST Controllers10 lessons
Expose endpoints that accept and return JSON, with the right status codes, DTOs and controller tests.
- @RestController and @RequestMapping40 min
- @GetMapping, @PostMapping, @PutMapping, @PatchMapping, @DeleteMapping45 min
- @PathVariable and @RequestParam45 min
- @RequestBody: reading JSON into objects45 min
- ResponseEntity and status codes45 min
- Request and response DTOs50 min
- Returning 201 Created with a Location header40 min
- Testing controllers with @WebMvcTest50 min
- Practice: REST controllers55 min
- Mini project: ShopLite category endpoints60 min
15.5Layered Architecture in Spring7 lessons
Split an application into controller, service and repository layers with clear jobs, organised by feature.
15.6Validation7 lessons
Reject bad input at the edge of the application with clear messages, and keep business rules in the service.
15.7Exception Handling7 lessons
Return one consistent ProblemDetail error format instead of stack traces.
- Default Spring error responses40 min
- Custom exceptions such as NotFound and Conflict45 min
- @RestControllerAdvice and @ExceptionHandler50 min
- Validation error responses with field details55 min
- ProblemDetail and RFC 9457 errors55 min
- Practice: exception handling50 min
- Mini project: ShopLite global error handling60 min
15.8Configuration, Profiles & Logging8 lessons
Change behaviour between development and production without changing code, log what matters, and expose health checks.
- application.properties vs application.yml40 min
- @Value and @ConfigurationProperties45 min
- Profiles: dev, test and prod45 min
- Environment variables and secrets45 min
- Logging with SLF4J: levels and what to log45 min
- Health checks with Spring Boot Actuator45 min
- Practice: configuration, profiles and logging50 min
- Mini project: ShopLite configuration and profiles60 min
15.9API Documentation with OpenAPI6 lessons
Generate interactive API docs that other developers can read and try out.
15.10Spring Boot Mini Project: ShopLite REST API7 lessons
Rebuild ShopLite as a Spring Boot REST API on MySQL, moving the JDBC DAOs to JdbcClient repositories with transactional order placement.
- Connecting Spring Boot to MySQL40 min
- From DAO classes to JdbcClient and JdbcTemplate repositories45 min
- Transactions with @Transactional50 min
- Practice: Spring Boot review and interview drill60 min
- Project: ShopLite catalog on MySQL90 min
- Project: ShopLite customers and orders120 min
- Project: ShopLite REST API release90 min
