Spring Boot Roadmap : Learn Spring Step by Step
Confused where to start with Spring Boot? Follow this simple roadmap, from basics to JPA, security and testing, built for freshers and interview prep in India.

How to use this RoadMap
Follow the phases in order. AOP, transactions and security all rest on how the container creates and wraps beans.
For each section, explain the key idea aloud in two minutes, then prove it with a tiny project.
Use the checkpoints: answer them without notes.
Suggested phases
Foundation (Sections 1, 2): understand how Spring builds and wires an app.
Web and data (Sections 4, 5, 7): build a REST API backed by a database.
Correctness and safety (Sections 3, 6, 8): understand proxies, transactions and security.
Quality and operations (Sections 9, 11): test, cache, schedule and observe.
Mastery (Sections 10, 12): extend the container and reason about internals.
1. Core Foundations
Key idea: Your code does not create or look up its collaborators. The container creates objects (beans), wires them together and manages their lifecycle. That is Inversion of Control.
Concepts
IoC and DI: IoC is the principle, DI is the mechanism.
BeanFactory vs ApplicationContext: the basic container vs the full one (events, i18n, resources, environment). You always use ApplicationContext.
Beans and the bean lifecycle: instantiate, inject dependencies, aware callbacks, BeanPostProcessor (before),
@PostConstruct, BeanPostProcessor (after), ready,@PreDestroy.Scopes: singleton (default), prototype, request, session, application.
Component scanning and stereotypes:
@Component,@Service,@Repository,@Controller,@RestController.Java config:
@Configuration+@Bean; why@Configurationclasses are CGLIB-proxied.Injection styles: constructor, setter, field. Prefer constructor injection.
Disambiguation:
@Qualifier,@Primary.Configuration:
@Value,@ConfigurationProperties, Environment and PropertySources, Profiles, Relaxed Binding.
Common traps
A singleton holding a prototype or request-scoped bean keeps one instance forever. Use a scoped proxy,
ObjectProvideror@Lookup.Singletons are shared across threads, so keep them stateless or thread-safe.
Field injection hides dependencies and hurts testability.
@Valuedoes not support relaxed binding;@ConfigurationPropertiesdoes.
Checkpoint
What happens between
SpringApplication.run()and a bean being ready?Why is constructor injection preferred?
Spring singleton scope vs the Singleton design pattern?
2. Auto-Configuration and Spring Boot Specifics
Key idea: Boot is Spring plus opinionated defaults. Auto-configuration registers beans conditionally and backs off when you define your own.
Concepts
@SpringBootApplication=@Configuration+@EnableAutoConfiguration+@ComponentScan.Auto-configuration: candidates listed in
META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports, filtered by conditions.Starters: curated dependency bundles (
spring-boot-starter-web,-data-jpa,-security,-test).Conditionals:
@ConditionalOnClass,@ConditionalOnMissingBean,@ConditionalOnProperty,@ConditionalOnBean.Externalized config:
application.properties/.yml, profile files, environment variables, command-line args.Precedence (simplified, high to low): command-line args, system properties, OS env vars, profile files, default file, code defaults.
Actuator basics:
/health,/info,/metrics.
Common traps
Component scan covers only the main class's package and below.
Defining your own bean usually disables the auto-configured one.
Run with
--debugto see the conditions report.
Checkpoint
How does Boot decide to configure a
DataSource?How do you override a property per environment without changing code?
3. Aspect-Oriented Programming (AOP)
Key idea: Spring adds cross-cutting behavior by wrapping beans in proxies. Understand the proxy and most "magic" annotations stop being magic.
Concepts
Vocabulary: aspect, join point, pointcut, advice, weaving, target, proxy.
Advice:
@Before,@After,@AfterReturning,@AfterThrowing,@Around.Proxies: JDK dynamic proxy (interfaces) vs CGLIB (classes, Boot default). Spring AOP is runtime proxy-based, unlike AspectJ weaving.
Pointcuts:
execution(...),within(...),@annotation(...).Custom aspects: logging, timing, auditing with
@Aspectand a custom annotation.Real uses:
@Transactional,@Cacheable,@Async,@PreAuthorize.
Common traps
Self-invocation:
this.method()bypasses the proxy, so no advice runs.Only public methods on Spring-managed beans are advised by default.
finalclasses and methods cannot be CGLIB-proxied.
Checkpoint
Why does
@Transactionalfail on a same-class call?JDK proxy vs CGLIB: when is each used?
4. Spring MVC (Web Layer)
Key idea: Every request flows through one front controller, the DispatcherServlet, which delegates to handlers and converters.Concepts
Request flow: Filter, DispatcherServlet, HandlerMapping, HandlerAdapter, Interceptor, Controller, message converter, response.
Controllers:
@Controllervs@RestController.Mappings:
@RequestMapping,@GetMapping,@PostMapping,@PutMapping,@PatchMapping,@DeleteMapping.Binding:
@RequestBody,@ResponseBody,@PathVariable,@RequestParam,@RequestHeader.Converters and content negotiation: JSON via Jackson, driven by
AcceptandContent-Type.Responses:
ResponseEntity, status codes,ProblemDetail.Exception handling:
@ExceptionHandler,@RestControllerAdvice,ResponseStatusException.Filters vs interceptors: filters are servlet-level; interceptors are MVC-level with handler access.
Common traps
Returning entities directly leaks internals and causes serialization issues. Use DTOs.
Keep one consistent error response format.
Checkpoint
Trace
POST /usersfrom socket to JSON response.When would you pick a filter over an interceptor?
5. Spring Data JPA
Key idea: Repositories are interfaces; Spring generates the implementation. Hibernate tracks entity state in a persistence context.
Concepts
JPA vs Hibernate: specification vs implementation.
Mapping:
@Entity,@Table,@Column,@Id,@GeneratedValue,@Embeddable,@Enumerated.Relationships:
@OneToOne,@OneToMany,@ManyToOne,@ManyToMany, owning side,mappedBy.Cascade and fetch:
CascadeType,orphanRemoval, LAZY (preferred) vs EAGER.Repositories:
CrudRepository,PagingAndSortingRepository,JpaRepository.Queries: derived methods,
@Query(JPQL and native),@Modifying, projections.Pagination:
Pageable,PagevsSlice.Auditing:
@CreatedDate,@LastModifiedDate,@EnableJpaAuditing.EntityManager: entity states, dirty checking, flush.
Migrations: Flyway or Liquibase, not
ddl-auto=updatein production.
Common traps
N+1 selects: fix with
JOIN FETCH, entity graphs or batch fetching.LazyInitializationExceptionoutside a transaction.Bidirectional relationships need both sides kept in sync; write
equals/hashCodecarefully.Know what
spring.jpa.open-in-viewdoes before relying on or disabling it.
Checkpoint
What is the persistence context, and what does dirty checking do?
How do you diagnose and fix N+1?
6. Transaction Management
Key idea: @Transactional is an AOP proxy that opens a transaction before the method and commits or rolls back after it.Concepts
Declarative vs programmatic:
@TransactionalvsTransactionTemplate.Propagation:
REQUIRED(default),REQUIRES_NEW,NESTED,SUPPORTS,NOT_SUPPORTED,MANDATORY,NEVER.Isolation:
READ_UNCOMMITTED,READ_COMMITTED,REPEATABLE_READ,SERIALIZABLE, and the anomalies each prevents.Rollback rules: unchecked exceptions and errors by default; use
rollbackForfor checked ones.Read-only transactions and the transaction proxy (same rules as AOP).
Common traps
Catching an exception inside the method swallows the rollback.
@Transactionalon private or internally called methods does nothing.Long transactions around remote calls hold DB connections.
REQUIRES_NEWsuspends the outer transaction and uses another connection.
Checkpoint
A
REQUIREDmethod calls aREQUIRES_NEWmethod that throws. What happens?Why don't checked exceptions roll back by default?
7. Validation
Key idea: Declare constraints on the model and enforce them at the boundary.
Concepts
Jakarta Bean Validation:
@NotNull,@NotBlank,@NotEmpty,@Size,@Min,@Max,@Email,@Pattern,@Positive,@Past.@Validvs@Validated: cascading validation vs groups and method-level validation.Groups: different rules for create and update.
Custom validators: a constraint annotation plus a
ConstraintValidator, including cross-field rules.Error handling:
MethodArgumentNotValidException,ConstraintViolationException.
Common traps
@NotNull,@NotEmptyand@NotBlankdiffer by type and strictness.Validation does not replace database constraints or business rules.
Checkpoint
How would you validate that
endDateis afterstartDate?
8. Security (Spring Security Fundamentals)
Key idea: Security is a chain of servlet filters. Authentication establishes who you are; authorization decides what you may do.
Concepts
Architecture:
SecurityFilterChain,AuthenticationManager,AuthenticationProvider,SecurityContextHolder.Users:
UserDetailsService,UserDetails,GrantedAuthority.Password encoding: BCrypt or Argon2, never plain text.
Request rules:
authorizeHttpRequests.Method security:
@EnableMethodSecurity,@PreAuthorize,@PostAuthorize,@Secured.CSRF: protects cookie-based sessions; often disabled for stateless token APIs.
CORS: a browser policy configured on the server; different from CSRF.
Next step: JWT and OAuth2 resource server.
Common traps
Modern Spring Security uses a
SecurityFilterChainbean;WebSecurityConfigurerAdapteris removed.Filter order matters; CORS must be handled before authentication.
Checkpoint
What happens to a request to a protected endpoint with no credentials?
CSRF vs CORS: what does each prevent?
9. Testing Concepts
Key idea: Test the smallest slice of the context that proves the behavior.
Concepts
@SpringBootTest: full context, integration level (use sparingly).@WebMvcTest: controller layer with MockMvc.@DataJpaTest: JPA layer with a test database, rolled back per test.Mocking:
@MockBean/@SpyBean(newer:@MockitoBean/@MockitoSpyBean).Other slices:
@JsonTest,@RestClientTest. Add Testcontainers for realistic databases.
Common traps
Overusing
@SpringBootTestslows the suite.H2 can behave differently from your production database.
Many different mock combinations create many contexts and defeat caching.
Checkpoint
Which annotation would you use to test controller validation, and why?
10. Advanced Container Features
Key idea: The container is extensible; Spring AOP and Boot are built from these hooks.
Concepts
BeanFactoryPostProcessor: modifies bean definitions before creation.
BeanPostProcessor: modifies or wraps beans after creation (where proxies are made).
Events:
ApplicationEventPublisher,@EventListener,@TransactionalEventListener.@Lazy: defers initialization and can break cycles.Circular dependencies: redesign, setter injection,
@Lazy, or extract a third bean. Boot forbids them by default.@LookupandObjectProviderfor prototype-in-singleton.FactoryBean: a bean that produces another object.Lifecycle/SmartLifecycle: ordered start and stop, graceful shutdown.
Checkpoint
Where in the lifecycle is an AOP proxy created?
BeanPostProcessor vs BeanFactoryPostProcessor?
11. Cross-Cutting and Supporting Concepts
Key idea: Most are one annotation plus one enable switch, all proxy-based, so the proxy caveats from Section 3 apply.
Concepts
Logging: SLF4J with Logback, levels, MDC correlation IDs, structured logs.
i18n:
MessageSource,LocaleResolver, message bundles.Caching:
@EnableCaching,@Cacheable,@CacheEvict,@CachePut, keys, TTL via Caffeine or Redis.Scheduling:
@EnableScheduling,@Scheduled(fixed rate, fixed delay, cron).Async:
@EnableAsync,@Async,CompletableFuture, custom executors.Task execution:
TaskExecutor,ThreadPoolTaskExecutor,TaskScheduler.
Common traps
Self-invocation breaks
@Cacheableand@Asynctoo.Configure thread pools explicitly for production.
Scheduled jobs run on every instance unless you add distributed locking (for example ShedLock).
Cache with an eviction plan, or data goes stale.
Checkpoint
Why might
@Asyncappear to run synchronously?
12. Modern and Additional Topics
Virtual threads (Java 21+):
spring.threads.virtual.enabled=true; great for blocking I/O, not CPU-bound work.Observability: Micrometer metrics, tracing via OpenTelemetry, correlating logs, metrics and traces.
Native image and AOT: GraalVM builds, with limits on reflection and dynamic proxies.
Package structure: package-by-feature over package-by-layer; optionally Spring Modulith.
Jakarta namespace: Boot 3 uses
jakarta.*and requires Java 17+.
Recommended additions
REST clients:
RestClient,WebClient, HTTP interfacesDatabase migrations: Flyway or Liquibase
API docs: OpenAPI / springdoc
Resilience: timeouts, retries, circuit breakers (Resilience4j)
Messaging: Kafka or RabbitMQ basics
Deployment: layered JARs, Docker or buildpacks, health probes
Reactive stack (optional): WebFlux and Reactor
Capstone projects
REST API: entities with relationships, DTOs, validation, global error handling, pagination.
Secured version: Spring Security with JWT, roles and method-level authorization.
Production-ready version: caching, scheduled cleanup, events, Actuator and Micrometer, Testcontainers tests, Docker image.
One-page mental model
Container: builds and wires beans.
Boot: chooses beans for you based on conditions.
Proxies: add transactions, caching, async and security around beans.
MVC: maps HTTP to controller methods through converters.
Data JPA: repositories over a persistence context, inside a transaction.
Security: a filter chain in front of everything.
Tests: slice the context to the layer under test.


