Learn Spring Boot by building one Bookstore REST API from an empty project to a secured, tested, microservices-ready app — beans and DI, configuration, Spring MVC, Spring Data JPA, transactions, AOP, Spring Security with JWT, Actuator, testing, and Spring Cloud.
Spring Boot is a Java framework. Be comfortable with Java before starting — the Spring parts you pick up as you build.
Before you start
To follow along on your computer:
bookstore project grows as you go. Run it with ./mvnw spring-boot:run and open http://localhost:8080 to see your work.Create & Run a Spring Boot Project
Generate a project with Spring Initializr, understand starters and autoconfiguration, run the embedded server, and write your first REST endpoint.
Beans, IoC & Dependency Injection
Let Spring create and wire your objects. Declare beans with stereotype annotations, inject them through the constructor, and control scope and ambiguity.
Configuration & Profiles
Externalize settings instead of hard-coding them — properties and YAML, @Value, type-safe @ConfigurationProperties, per-environment profiles, and secrets from the environment.
Building REST APIs with Spring MVC
Map HTTP to Java methods — path variables, query params, JSON request bodies, status codes with ResponseEntity, bean validation, and clean error handling.
Data Persistence with Spring Data JPA
Store and query data without writing SQL boilerplate — map entities with JPA/Hibernate, get CRUD for free from a repository, and write derived and custom queries.
Entity Relationships
Model how tables connect — one-to-many, many-to-one, many-to-many, and one-to-one — and control fetching, cascading, and the N+1 query problem.
Transactions
Keep your data consistent — wrap multi-step work in @Transactional so it all commits or all rolls back, and control rollback rules, propagation, and read-only access.
Spring Data JDBC & MongoDB
Spring Data is one programming model for many stores. Use the lighter Spring Data JDBC for simple SQL, and Spring Data MongoDB for documents — with the same repository style.
Spring AOP
Pull cross-cutting concerns — logging, timing, auditing — out of your business code into reusable aspects that run around your methods automatically.
Spring Security: Authentication & Authorization
Lock down your API — configure the security filter chain, authenticate users with a UserDetailsService and password encoder, and authorize requests by role.
JWT & OAuth2
Secure a stateless API with JSON Web Tokens, validate them as an OAuth2 resource server, and let users log in through an external provider with OAuth2 login.
Actuator & Metrics
Make your app observable in production — expose health, info, and metrics endpoints with Actuator, add a custom health check, and record metrics with Micrometer.
Testing
Test every layer — slice tests for the web and data layers with MockMvc and @DataJpaTest, full integration tests with @SpringBootTest, and fake collaborators with @MockBean.
Microservices with Spring Cloud
Split the monolith — register services with Eureka, route through Spring Cloud Gateway, centralize settings with Config Server, call services with OpenFeign, and add a circuit breaker.
Real-Time Data with WebSockets
Push live updates to the browser. Add WebSocket support to the Bookstore, handle raw text messages, register the endpoint, broadcast order updates over STOMP, and connect from the browser.