Frameworks
Build Java services with Spring Boot: IoC, security, data access, microservices, MVC and testing.
A path for Java developers building backend services with Spring Boot. It starts with the core container — dependency injection, beans, AOP and configuration — then covers security, starters, auto-configuration, actuators, Hibernate and Spring Data, Spring Cloud microservices, Spring MVC and testing. Each subject links the official documentation.
The subjects follow the roadmap.sh Spring Boot roadmap.
Spring Framework is a modular Java platform built around an inversion-of-control container that creates your objects and wires them together, with modules for web, data access, messaging and testing. Spring Boot sits on top and removes most setup with opinionated defaults, starters and an embedded server, so a production-ready service is one main method away.
A huge, well-maintained ecosystem covering web, data, security, messaging and cloud, consistent programming model across all of it, strong testing support and long-term commercial backing. The trade-off is "magic" you need to learn to debug.
Bean (an object the container manages), ApplicationContext (the container), component scanning, configuration classes, profiles, properties and starters — the vocabulary every Spring error message and doc page assumes.
Beans are declared with @Configuration classes and @Bean methods or discovered through component scanning; Boot externalises settings into application.properties/.yml, environment variables and profiles, bound type-safely with @ConfigurationProperties.
Objects receive their collaborators instead of constructing them. Prefer constructor injection with final fields (a single constructor needs no @Autowired); it makes dependencies explicit and classes easy to unit test.
Inversion of control means the container, not your code, controls object creation and lifecycle. It reads bean definitions, resolves the dependency graph, applies post-processors (which is how proxies get added) and calls init and destroy callbacks.
Aspect-oriented programming wraps beans in proxies to add cross-cutting behaviour such as transactions, security and caching. Because it is proxy-based, calling an advised method from inside the same class bypasses the aspect.
Stereotypes (@Component, @Service, @Repository, @RestController), wiring (@Bean, @Qualifier, @Value), web mapping (@GetMapping, @RequestBody) and Boot's @SpringBootApplication, which combines configuration, auto-configuration and scanning.
Singleton (one per container, the default), prototype (new on every lookup), and web scopes: request, session and application. Injecting a shorter-lived bean into a singleton needs a scoped proxy or an ObjectProvider.
The standard framework for authenticating users and authorising requests in Spring apps, implemented as a chain of servlet filters. In current versions you configure it by declaring a SecurityFilterChain bean with the lambda DSL; adding the starter alone locks every endpoint behind a generated password.
Establishing who the caller is: an AuthenticationManager delegates to providers that check form logins, HTTP Basic, tokens or LDAP, backed by a UserDetailsService and a PasswordEncoder such as BCrypt.
Deciding what an authenticated caller may do, either per URL with authorizeHttpRequests rules or per method with @PreAuthorize("hasRole('ADMIN')") after enabling method security.
Spring Security supports OAuth 2.0 login with external identity providers (oauth2Login), acting as a client calling protected APIs, and acting as a resource server that validates access tokens.
For stateless APIs, configure the app as an OAuth2 resource server with jwt(): tokens are verified against the issuer's keys and their claims mapped to authorities. Avoid hand-rolled JWT filters where the built-in support fits.
Starters are dependency descriptors such as spring-boot-starter-web, -data-jpa, -security or -test that pull in a tested set of libraries for one capability. Combined with the Boot parent or BOM, they also pin compatible versions, so you rarely specify a version yourself.
Boot inspects the classpath, existing beans and properties, then registers sensible beans through @Conditional... rules — a DataSource when a JDBC driver is present, for example. Your own beans always win. Run with --debug to print the conditions report explaining what was applied and why.
The actuator starter adds operational endpoints under /actuator: health (with liveness and readiness groups for Kubernetes), info, metrics, env, loggers and more. Expose only what you need with management.endpoints.web.exposure.include and secure the rest.
Boot runs Tomcat (default), Jetty or Undertow inside the application, so you ship a single executable jar instead of deploying a WAR. Tune it with server.* properties such as server.port and enable virtual threads on Java 21 with spring.threads.virtual.enabled.
The JPA implementation Spring Boot uses by default, mapping Java entities to tables and generating SQL. It is productive but leaky: understanding the persistence context, fetching strategies and generated queries is essential to avoid N+1 queries and surprising updates.
Annotate service methods with @Transactional to run them in one transaction, rolled back on unchecked exceptions by default. It is proxy-based, so self-invocation and private methods are not transactional; use readOnly = true for queries.
@OneToMany, @ManyToOne, @OneToOne and @ManyToMany map foreign keys between entities. Make @ManyToOne lazy explicitly, keep the owning side clear with mappedBy, and load associations deliberately with fetch joins or entity graphs.
Entities move between transient, managed, detached and removed states. Changes to managed entities are flushed automatically at commit (dirty checking), and @PrePersist/@PreUpdate callbacks hook into transitions.
An umbrella project that gives every data store the same repository programming model: declare an interface, and Spring generates the implementation, including queries derived from method names like findByEmail. Each store module adds its own specifics.
Repositories over JPA/Hibernate with JpaRepository, derived queries, @Query with JPQL or native SQL, paging with Pageable, projections and specifications for dynamic filters.
Maps documents to Java objects with @Document, offers MongoRepository and the lower-level MongoTemplate for aggregations and partial updates.
A simpler alternative to JPA with no lazy loading, caching or dirty checking: aggregates are loaded and saved whole with plain SQL, which keeps behaviour predictable.
Splitting a system into independently deployable services, each owning its data. Spring Boot makes each service cheap to build; the hard parts are distributed concerns such as configuration, discovery, resilience and observability, which Spring Cloud addresses.
A family of projects for distributed systems on top of Boot: configuration, service discovery, gateways, circuit breakers and declarative clients. Match its release train to your Boot version.
An API gateway that routes requests to services by path, host or header predicates and applies filters for rate limiting, retries, rewriting and authentication.
A config server serving properties from Git, Vault or a database to every service, so settings change centrally per environment. Clients import it with spring.config.import=configserver:.
An abstraction over circuit breaker libraries, usually Resilience4j, that stops calling a failing dependency for a while and returns a fallback, preventing cascading failures.
Declarative HTTP clients: annotate an interface with @FeignClient and Spring generates the implementation. The project is now feature-complete, and Spring's own HTTP interface clients are the suggested alternative for new code.
The metrics and tracing facade behind Boot's observability: counters, timers and gauges exported to Prometheus, Datadog and others, plus the Observation API for traces.
Netflix's service registry, integrated through Spring Cloud Netflix: services register themselves and look each other up by name. On Kubernetes, the platform's own service discovery usually replaces it.
Spring's servlet-based web framework for REST APIs and server-rendered pages. Controllers map requests to handler methods, and message converters turn Java objects into JSON and back. Spring WebFlux is the reactive alternative.
The Jakarta Servlet API underneath Spring MVC: a container like Tomcat hands each request to a servlet on a worker thread. Filters run before it, which is where Spring Security lives.
JavaServer Pages are a legacy view technology with limited support in executable-jar Boot apps. New server-rendered projects use Thymeleaf or another template engine instead.
A front controller, the DispatcherServlet, receives every request, asks handler mappings which controller method applies, invokes it through a handler adapter and resolves the result into a view or a serialised body.
The pluggable pieces the dispatcher relies on: HandlerMapping, HandlerAdapter, HandlerExceptionResolver (used by @ControllerAdvice), ViewResolver and HttpMessageConverters, plus interceptors around handlers.
spring-boot-starter-test bundles JUnit 5, AssertJ, Mockito and Spring's test support. Use plain unit tests for logic, slice tests that start only one layer, and full-context tests sparingly; Testcontainers gives integration tests a real database.
@DataJpaTest starts only JPA components and repositories, runs each test in a rolled-back transaction and by default swaps in an embedded database; pair it with Testcontainers to test against the real engine.
Exercises controllers through the full MVC stack without a running server: perform a request, then assert on status, headers and JSON. @WebMvcTest creates a slice with just the web layer.
Boots the whole application context, optionally with a real server on a random port (webEnvironment = RANDOM_PORT). Thorough but slow; contexts are cached between tests with identical configuration.
Replaced a bean in the test context with a Mockito mock. It is deprecated since Boot 3.4 in favour of the framework's @MockitoBean, which works the same way. Each distinct set of mocks creates a new context.