Spring Boot Words Explained: Bean, ApplicationContext, Auto-Configuration, DispatcherServlet

October 1, 2026 · How It Actually Works: Real Systems as State Machines (part 2)

▶ Watch on YouTube & subscribe to The Stack Underflow

The Spring Boot lifecycle video uses a lot of words: bean, application context, auto-configuration, DispatcherServlet, proxy, readiness. This primer explains each one with a single example, a bookstore app answering GET /books/42, and one map that fills in as you go. It targets Spring Boot 4 and Spring Framework 7.

The one-line version: the ApplicationContext creates and wires your beans; Boot adds starters, auto-configuration and an embedded server; a request passes filters, then the DispatcherServlet, then your code through proxies; and “Started” is not “Ready”.

Last verified against the Spring Boot 4.1.1 and Spring Framework 7.0.9 reference documentation: 1 October 2026. The video’s definitions were checked on 29 September 2026 against the same versions; the version-specific ones (Boot 4 requires Framework 7, the starter rename, embedded servers and port, @Transactional defaults) were re-checked today.

One picture: a restaurant

Every word gets a peg from one picture, a restaurant. The pegs are analogies, memory aids, not definitions; the right-hand column is the real meaning, and the limits are covered in the sections below.

WordMemory peg (analogy)What it actually is
Spring Framework vs Spring Bootthe kitchen kit vs the ready-to-open restaurantThe Framework is the foundation (container, Spring MVC, transactions). Boot is a separate project on top that adds starters, auto-configuration and an embedded server. Boot 4 requires Framework 7
ApplicationContextthe managerThe Spring IoC container: it instantiates, configures and assembles the beans
Beanhired staffAn object the container creates, assembles and manages. An object you create with new is not a bean
Dependency injectiontools handed overA class declares what it needs (here, through its constructor) and the container supplies it
@Component and stereotypesjob-title badges@Component makes a bean; @Service, @Repository, @Controller also name its layer
Starters + auto-configurationthe fit-out packageA starter only brings libraries; auto-configuration adds default beans, and backs off when you define your own
application.yaml + profilesthe settings board (weekday and weekend versions)Settings outside the code; a profile is a named set of settings for one environment
@ConfigurationPropertiesa whole board sectionBinds a group of settings, like bookstore.*, to a typed, validatable object
Embedded server vs WARfood truck vs food hallBoot runs Tomcat inside your JVM; a WAR is deployed into a separate servlet container
DispatcherServletthe head waiter at the passSpring MVC’s front controller servlet: finds the handler and writes the result
Servlet filterdoor securityRuns before the servlet (and on the way out); belongs to the servlet container
HandlerInterceptorthe head waiter’s checkSpring MVC’s hook around a chosen handler: preHandle, postHandle, afterCompletion
Controller / servicethe waiter and the chefHTTP in and out vs business logic
@Transactional proxythe tab supervisorA proxy in front of the bean that starts or joins a transaction, then commits or rolls back
Entitythe ledger entryA JPA class whose objects map to table rows
DAO vs repositorythe stock clerk (you train vs the agency supplies)A DAO is a class you write; a Spring Data repository is an interface Spring implements at run time
DTOthe plate as servedA plain object that only carries data, shaped for the API
@PostConstruct / @PreDestroyopening and closing checklistsPer-bean callbacks after injection and when the context closes
Started vs Readylights on vs doors openContext refreshed vs runners finished and accepting traffic
Runnersprep before openingBeans with one run method, called just before SpringApplication.run() completes
Liveness vs readinesskitchen alive? vs seating guests?Restart the app vs send it traffic now

The container and its beans

The ApplicationContext is the IoC container. Inversion of control means your classes don’t create their collaborators; the container does. It’s often confused with BeanFactory, the basic container interface. ApplicationContext extends it and adds events, message resources and AOP integration.

A bean isn’t a special kind of class. The same class becomes a bean only when the container creates and manages the object.

With constructor injection, BookController’s constructor takes a BookService, and Spring passes in that bean. A class with a single constructor needs no @Autowired. The Spring team recommends constructor injection for required dependencies (immutable, never null). Field injection happens after construction, so an injected field isn’t set yet inside the constructor.

@RestController
class BookController {
    private final BookService books;
    BookController(BookService books) { this.books = books; }  // one constructor: no @Autowired needed
}

Component scanning finds @Component classes and their specializations. @Repository adds behaviour on top of naming the layer: exception translation into Spring’s DataAccessException hierarchy (the peg’s “house language”). @RestController is @Controller plus @ResponseBody.

What Spring Boot adds

A starter is a dependency descriptor. In Boot 4, spring-boot-starter-webmvc (Spring MVC and Tomcat) replaces the deprecated spring-boot-starter-web. Starters only bring libraries. Auto-configuration then adds the beans you’d otherwise write, based on what’s on the class path, and backs off when you define your own: add your own DataSource bean and the default embedded database support backs away. Back-off is per condition, not all-or-nothing.

application.yaml (or .properties) holds settings outside the code; environment variables and command-line arguments can override it. A profile-specific file such as application-prod.yaml applies only when prod is active (spring.profiles.active). It’s the same jar with different settings. @Value injects one property at a time; @ConfigurationProperties binds a whole group into a typed object.

The webmvc starter brings embedded Tomcat, listening on port 8080 by default (Boot also supports embedded Jetty for servlet apps). Boot still supports traditional WAR deployment, but the lifecycle video covers only the executable jar. Tomcat is created in onRefresh() and binds its port in finishRefresh().

Following GET /books/42

client → Tomcat → servlet filters (Spring Security) → DispatcherServlet
       → HandlerInterceptor.preHandle → BookController → @Transactional proxy → BookService
       → BookRepository → SQL → Book entity → BookDto → JSON (Jackson)

Filter vs interceptor is the classic confusion. Filters belong to the servlet container and run before the DispatcherServlet, and again on the way out. They can change the request or answer by themselves. Spring Security is a chain of filters, so it can reply 401 or 403 before your controller is reached. Interceptors run inside the DispatcherServlet once the handler is chosen; if preHandle returns false, the handler isn’t called. For security, the Spring docs recommend Spring Security or the filter chain, not interceptors.

The controller deals with HTTP; the service holds business logic. Keeping HTTP out of the service is a design choice that lets other callers, such as a test, use it.

The proxy trap: because BookService is @Transactional, callers get a proxy. The proxy starts or joins a transaction (default propagation REQUIRED), calls the real method, then commits, or rolls back on a RuntimeException or Error. By default it does not roll back on checked exceptions. In the default proxy mode, only external calls through the proxy are intercepted, so a call between two methods of the same class starts no transaction.

Entity, repository, DTO

An entity is a JPA (Jakarta Persistence) concept, not a Spring one: a class annotated @Entity with an @Id primary key, each object mapping to one row. Boot’s JPA starter uses Hibernate. An entity isn’t a bean.

A DAO is a pattern, a class you write to hide data access. A Spring Data repository is an interface: BookRepository extends JpaRepository typed to Book and Long, and Spring Data creates a proxy implementation at run time. findById comes with it; findByTitle becomes a query derived from the method name.

A DTO carries data between layers. BookService copies the fields the client should see into a BookDto, and Spring MVC converts it to JSON with Jackson. Nothing forces you to use one; it lets you choose what the JSON contains.

Startup, shutdown and health

  • @PostConstruct runs once per bean, after dependency injection; @PreDestroy runs when the context closes. Both come from Jakarta Annotations. They’re per bean, “as each is hired”, not when the app opens to traffic.
  • ApplicationStartedEvent is sent after the context is refreshed but before any runners. ApplicationReadyEvent is sent after the runners, and right after it readiness switches to ACCEPTING_TRAFFIC. Where the peg stops fitting: Tomcat’s port is already bound before “Started”.
  • CommandLineRunner gets the arguments as a String array; ApplicationRunner gets an ApplicationArguments object. @Order sets their order.
  • Actuator exposes the liveness and readiness health groups as /actuator/health/liveness and /actuator/health/readiness. A broken liveness state means the platform should restart the app; a failing readiness state only stops traffic.

Pause & Prove

1. saveAll() in BookService calls this.save(), which is annotated @Transactional. Does save() start a transaction?

  • A. Yes, the annotation is on the method. Tempting, but the annotation only works through the proxy.
  • B. No: the call never passes through the proxy. ✓ Callers get the proxy; this.save() is a self-invocation inside the target object, so no transaction starts. The chef calling their own station.
  • C. Only if saveAll() is public. Visibility of the caller doesn’t route the call through the proxy.
  • D. Only if it throws. Rollback rules apply inside a transaction; there isn’t one here.

2. A request reaches a Spring MVC app. Which runs first? (Community poll)

  • A servlet filter ✓ Filters belong to the servlet container and run before the DispatcherServlet.
  • A HandlerInterceptor. Runs inside the DispatcherServlet, after the handler is chosen.
  • Your controller. Runs after the filters, mapping and preHandle.
  • The @Transactional proxy. Only when the controller calls the service.

3. Peg drill

Say the peg first: bean → hired staff · repository → the stock clerk · DTO → the plate as served.

Before / after this video

Sources

Change notes

  • 1 Oct 2026: first published.

Not affiliated with or endorsed by VMware Broadcom (Spring). Spring is a trademark of Broadcom Inc. and/or its subsidiaries. Found a mistake? Tell us in the video’s comments and we’ll correct this page.

Found this useful? The deep version lives on YouTube — new breakdowns of how AI dev tools actually work, weekly.

Subscribe on YouTube →

Prefer email? Get the free newsletter: one failure, traced step by step, about once a week.