Skip to content
Tutorials Center
My learning

Topics

Spring Boot Tutorial

Learn Spring Boot step by step: 66 lessons in 11 chapters with examples, quizzes, diagrams and projects.

Start learning →

of lessons completed

Getting Started

  1. 1 What Is Spring Boot? What Spring Boot is, how it differs from the Spring Framework, which defaults it chooses for you, and what changed between Boot 3 and Boot 4.
  2. 2 Creating a Project Create a Spring Boot project with Spring Initializr, understand pom.xml and build.gradle, the wrapper, the folder layout and DevTools.
  3. 3 Your First Application Write and run your first Spring Boot app: @SpringBootApplication, a hello endpoint, starting and stopping, reading the startup log and the banner.
  4. 4 Starters and Dependency Management What a Spring Boot starter is, how the BOM manages versions, how to override a version, exclude a transitive dependency and read the dependency tree.

Inversion of Control and Beans

  1. 5 IoC and Dependency Injection Understand inversion of control and dependency injection in Spring Boot, why constructor injection wins, and build a tiny IoC container with reflection.
  2. 6 Component Scanning and Stereotypes How Spring Boot finds beans: @Component, @Service, @Repository, @Controller, scan packages, bean names and the meta-annotations behind @SpringBootApplication.
  3. 7 @Configuration and @Bean Define Spring beans in Java with @Configuration and @Bean: bean names, dependencies as parameters, proxyBeanMethods, importing configs and third-party beans.
  4. 8 Bean Scopes and Lifecycle How long Spring beans live and what happens when: singleton and prototype scopes, @PostConstruct and @PreDestroy, SmartLifecycle phases and startup order.
  5. 9 Qualifiers, @Primary and Collections Resolve multiple Spring bean candidates with @Primary and @Qualifier, inject all beans as a List or Map, use ObjectProvider, and avoid circular dependencies.
  6. 10 Conditional Beans Register Spring beans only when conditions hold: @Profile, @ConditionalOnProperty, @ConditionalOnClass, @ConditionalOnMissingBean and custom Condition classes.
  7. 11 Application Events and Runners Run code at startup with ApplicationRunner and CommandLineRunner, react to ApplicationReadyEvent, publish custom events and order @EventListener methods.
  8. 12 Aspects in Spring Boot (AOP) Add logging, timing and security checks to many beans without touching their code: Spring AOP in Boot, pointcuts, advice types, weaving, proxies and AspectJ.

Auto-Configuration and Configuration

  1. 13 How Auto-Configuration Works See how Spring Boot auto-configuration finds, orders and conditionally applies configuration classes, backs off for your beans, and how to read the debug report.
  2. 14 Writing Your Own Starter Build a custom Spring Boot starter: the autoconfigure module, a properties class, the imports file, metadata, back-off conditions and ApplicationContextRunner tests.
  3. 15 Properties, YAML and Externalized Config How Spring Boot reads application.properties and application.yml, which property source wins, how environment variables and relaxed binding work, and how placeholders resolve.
  4. 16 Type-Safe @ConfigurationProperties Bind application.yml to typed Java records with @ConfigurationProperties: nested objects, durations, data sizes, validation, defaults and configuration metadata.
  5. 17 Profiles and Environment-Specific Config Use Spring Boot profiles to change configuration and beans per environment: activation, profile files, groups, @Profile expressions, config import and secrets handling.
  6. 18 Logging Configure Spring Boot logging with SLF4J and Logback: levels, groups, patterns, JSON logs, MDC correlation IDs, and the pitfalls of string concatenation and leaked secrets.

Building REST APIs

  1. 19 REST Controllers Build REST endpoints in Spring Boot with @RestController, @GetMapping and friends, path variables, request params, status codes, ResponseEntity and content negotiation.
  2. 20 Request and Response Bodies with Jackson How Spring Boot turns JSON into Java objects and back: @RequestBody, records as DTOs, message converters, Jackson settings, dates and DTO vs entity.
  3. 21 Bean Validation Validate request data in Spring Boot with @Valid and Jakarta constraints: built-in annotations, groups, custom constraints and method validation.
  4. 22 Error Handling and Problem Details Return consistent errors from a Spring Boot API: @RestControllerAdvice, @ExceptionHandler, ProblemDetail (RFC 9457) and no leaked stack traces.
  5. 23 Designing a Clean API Design a clean Spring Boot REST API: resource names, pagination, sorting and filtering, versioning, idempotency keys, HATEOAS and OpenAPI docs.
  6. 24 DTO Mapping with MapStruct and ModelMapper Why REST APIs use DTOs, how to map entities by hand, with MapStruct or with ModelMapper, how to handle nested objects, collections and partial updates, and the pitfalls.
  7. 25 Filters, Interceptors and Argument Resolvers Run code around every request in Spring Boot: servlet filters, HandlerInterceptor, ordering, request logging, CORS and custom argument resolvers.
  8. 26 Calling Other Services (RestClient and HTTP Interfaces) Call other services from Spring Boot with RestClient and @HttpExchange interfaces: timeouts, retries, error handling, WebClient and MockRestServiceServer.
  9. 27 Server-Side Views with Thymeleaf Build HTML pages in Spring Boot with Thymeleaf: models and view names, forms and validation errors, fragments, escaping, and when SSR beats a JSON API.
  10. 28 File Uploads, Downloads and Static Resources Handle files safely in Spring Boot: MultipartFile uploads, size limits, content type checks, path traversal defense, Resource downloads and static content.

Data Access

  1. 29 DataSource, Connection Pools and JdbcClient Connect Spring Boot to a database: DataSource auto-configuration, HikariCP pool settings, JdbcClient queries, schema.sql and data.sql, and the H2 console.
  2. 30 Spring Data JPA Repositories Use Spring Data JPA in Boot: entities, JpaRepository, derived queries from method names, @Query, projections, paging and sorting, and auditing.
  3. 31 Entity Relationships and the N+1 Problem Map OneToMany, ManyToOne and ManyToMany in Spring Boot, understand lazy and eager fetching, and fix the N+1 query problem with join fetch and entity graphs.
  4. 32 Transactions with @Transactional Understand @Transactional in Spring Boot: how proxies start transactions, rollback rules, propagation, isolation, readOnly and the self-invocation pitfall.
  5. 33 Database Migrations with Flyway Version your schema like code with Flyway in Spring Boot: naming rules, checksums, repeatable scripts, baselining, ddl-auto pitfalls and zero-downtime changes.
  6. 34 Testing the Data Layer Test repositories and queries in Spring Boot with @DataJpaTest, rollback, flush, fixtures and Testcontainers, and learn when an in-memory database misleads you.
  7. 35 Caching Speed up a Spring Boot app with @Cacheable and @CacheEvict, pick Caffeine or Redis, set TTLs, and avoid stale data, self-invocation bugs and cache stampedes.
  8. 36 Spring Data MongoDB, Redis and Other Stores Learn when a document or key-value store beats SQL, how Spring Data MongoDB repositories and Redis templates work, and how to choose a data store in Spring Boot.

Security

  1. 37 Spring Security Fundamentals Learn what Spring Security does by default in Spring Boot, how to write a SecurityFilterChain, store passwords safely, and protect methods with roles.
  2. 38 JWT and OAuth 2 Resource Server Secure a stateless Spring Boot API with JWTs: how tokens are signed and validated, scopes and roles, issuers, refresh tokens and login with an OAuth 2 provider.
  3. 39 CSRF, CORS and Secure Defaults Harden a Spring Boot app: when CSRF protection matters, SameSite cookies, CORS rules, security headers, rate limiting, secrets and risky default settings.

Testing

  1. 40 Testing Spring Boot Applications Start testing Spring Boot: spring-boot-starter-test, unit tests versus @SpringBootTest, test slices, JUnit 5 with AssertJ, and the test pyramid.
  2. 41 Testing Controllers with MockMvc Test Spring Boot controllers fast with @WebMvcTest, MockMvcTester and @MockitoBean: status codes, JSON assertions, validation errors and security.
  3. 42 Integration Tests with Testcontainers Test against real PostgreSQL, Redis or Kafka from Spring Boot with Testcontainers: @ServiceConnection, dynamic properties, reuse and CI tips.
  4. 43 Test Slices, Context Caching and Test Speed Speed up Spring Boot tests: @JsonTest, @DataJpaTest, @RestClientTest, how the context cache keys work, @DirtiesContext cost, parallelism and flaky tests.
  5. 44 API Tests with REST Assured Write readable black-box HTTP and JSON tests for a running Spring Boot app with REST Assured's given-when-then style, plus a note on ZeroCode and when to choose each tool.
  6. 45 Code Coverage with JaCoCo Measure test coverage in a Spring Boot project with JaCoCo: Maven and Gradle setup, line versus branch coverage, reading the report, thresholds, exclusions and a CI gate.

Production Features

  1. 46 Actuator: Health, Metrics and Info Monitor a Spring Boot app with Actuator: endpoints, exposure and security, health groups and Kubernetes probes, custom HealthIndicators and info.
  2. 47 Observability: Metrics, Tracing and Logs See inside a running Spring Boot app: Micrometer counters and timers, the Prometheus format, OpenTelemetry traces, log correlation, dashboards and alerts.
  3. 48 Scheduling and Asynchronous Work Run jobs on a schedule with @Scheduled and cron, move slow work off the request thread with @Async, tune executors, use virtual threads and shut down gracefully.
  4. 49 Messaging and Events Between Services Send and receive messages in Spring Boot with Kafka and RabbitMQ, understand at-least-once delivery, write idempotent consumers and use the outbox pattern.
  5. 50 Kafka with Spring Boot in Practice Create Kafka topics from Spring Boot, send and receive JSON, understand consumer groups and partitions, add retries with a dead-letter topic and start or stop listeners at run time.
  6. 51 Resilience: Timeouts, Retries and Circuit Breakers Keep a Spring Boot app alive when dependencies fail: timeouts, safe retries with backoff, circuit breakers, bulkheads, fallbacks, Resilience4j and @Retryable.
  7. 52 Microservices with Spring Cloud A map of Spring Cloud for Boot developers: monolith versus microservices, Eureka discovery, OpenFeign calls, Config Server and Gateway, with runnable stand-ins.
  8. 53 Performance Tuning Make a Spring Boot app faster the right way: measure first, size pools and threads, use virtual threads, trim startup, set JVM flags, profile and cut JSON cost.

Packaging and Deployment

  1. 54 Building and Running the Jar Build an executable Spring Boot jar with Maven or Gradle, see what is inside it, use layered jars, start it with java -jar and speed up startup with CDS and AOT caches.
  2. 55 Containers: Dockerfile and Buildpacks Package a Spring Boot app as a container image: layered Dockerfile, bootBuildImage buildpacks, non-root user, memory settings, health probes and image size.
  3. 56 Native Images with GraalVM Compile a Spring Boot app to a native executable with GraalVM: AOT processing, runtime hints, build time versus startup, limits and when it pays off.
  4. 57 Deployment: Cloud, Kubernetes and Config Deploy a Spring Boot service the 12-factor way: env and secret config, Kubernetes probes, graceful shutdown, zero-downtime rolling releases and a CI/CD pipeline.

Projects

  1. 58 Project: Todo REST API Build a complete Spring Boot Todo REST API: CRUD endpoints, validation, consistent errors, pagination and tests, with a runnable plain-Java model of the core.
  2. 59 Project: URL Shortener Service Build a URL shortener with Spring Boot: base62 ids, redirects, click counting, caching and rate limiting, with runnable plain-Java models of the core logic.
  3. 60 Project: Blog with Users and Roles Build a blog API with Spring Boot: registration with hashed passwords, HTTP Basic login, roles, ownership checks with method security and security tests.
  4. 61 Project: Bookstore Orders Service Build a bookstore orders service in Spring Boot: JPA model, Flyway schema, transactional order placement, safe stock updates, domain events and Testcontainers tests.
  5. 62 Project: Event-Driven Notifications Build reliable event-driven notifications in Spring Boot: domain events, the outbox pattern, a relay, a retrying listener, idempotency, dead letters and metrics.

Practice and Review

  1. 63 Practice Exercises with Solutions Fifteen graded Spring Boot exercises on dependency injection, configuration, REST, validation, JPA and security, each with a full solution and live stand-ins.
  2. 64 Common Mistakes and Debugging Startup Failures Read and fix common Spring Boot failures: NoSuchBean, circular dependencies, port in use, 404 versus 405, LazyInitializationException, self-invocation and debug mode.
  3. 65 Spring Boot Interview Questions 40 Spring Boot interview questions with concise answers on beans, auto-configuration, REST, JPA, security, testing and production, plus two predict-the-output examples.
  4. 66 Spring Boot Cheat Sheet A one-page Spring Boot cheat sheet: annotations, application properties, starters, test annotations, Actuator endpoints, status codes and everyday build commands.