Clean • Professional
The ApplicationContext is the core container of the Spring Framework and Spring Boot. It manages beans, configurations, dependency injection, environment, events, and much more.
Spring Boot builds on top of the standard ApplicationContext and adds features like:
ApplicationContext = Central IoC Container
It manages the complete Spring application by:
application.properties / application.ymlIt is an enhanced and more feature-rich version of BeanFactory.
Spring Boot uses different types of ApplicationContext depending on application type (Web MVC, Reactive, CLI, XML-based, etc.). Each ApplicationContext has its own purpose and lifecycle behavior.
Below are the most important and commonly used ApplicationContext types in Spring Boot.

Used For:
@Configuration classesKey Features:
@Configuration, @Component, @Service, etc.Example:
ApplicationContext context =
new AnnotationConfigApplicationContext(AppConfig.class);
Used For:
Key Features:
spring-boot-starter-webExample:
When you run a Spring Boot Web app:
SpringApplication.run(MyApplication.class, args);
Spring Boot internally creates this ApplicationContext.
Used For:
Key Features:
spring-boot-starter-webfluxExample:
Used automatically when WebFlux starter is included.
Used For:
Key Features:
Example:
GenericApplicationContext context = new GenericApplicationContext();
context.registerBean(MyService.class);
context.refresh();
(Mostly for internal or testing use)
Used For:
Key Features:
Spring Boot’s ApplicationContext internally consists of several powerful subsystems that work together to create, configure, and manage your entire Spring application.

Before creating any objects, Spring must first understand what needs to be created.
The Registry loads metadata from:
@Configuration classes@Component, @Service, @Repository@Bean methodsIt converts these inputs into Bean Definitions, which contain:
This acts as blueprints for bean creation.
Once BeanDefinitions are ready, BeanFactory creates and manages actual objects (beans).
Spring Boot uses:
➡ DefaultListableBeanFactory
Key responsibilities:
BeanPostProcessors@PostConstruct, @PreDestroy)This is the engine of the IoC container.
Spring Boot’s configuration system merges properties from multiple levels:
Priority order (high → low):
Features:
@Value@Profile, spring.profiles.active)Spring’s ApplicationContext includes a full event-driven system.
Spring Boot fires lifecycle events such as:
You can listen using:
@Component
class StartupListener implements ApplicationListener<ApplicationReadyEvent> {
public void onApplicationEvent(ApplicationReadyEvent event) {
System.out.println("Application is Ready!");
}
}
Internally uses:
Spring provides a unified approach to loading resources.
ApplicationContext can load:
Example:
resourceLoader.getResource("classpath:data.json");
This gives uniform access to various sources without writing custom file-handling code.
ApplicationContext includes a MessageSource that supports:
messages.properties)Example:
messageSource.getMessage("user.notFound", null, locale);
This is used automatically by:
This subsystem controls the lifecycle of the ApplicationContext and its beans.
Responsibilities:
LifecycleSmartLifecycle)Example:
When the application shuts down gracefully, LifecycleProcessor triggers stop() on relevant beans.
Below is the complete step-by-step internal lifecycle of Spring Boot’s ApplicationContext — from app start to fully running state.
SpringApplication.run() determines the correct context based on the application type:
AnnotationConfigServletWebServerApplicationContextAnnotationConfigReactiveWebServerApplicationContextAnnotationConfigApplicationContext➡ This is the very first object Spring Boot creates.
Before loading beans, Spring prepares the Environment:
application.properties / application.ymlapplication-dev.yml)➡ This produces a final resolved Environment used by the container.
Spring scans and registers BeanDefinitions from:
@Configuration classes@ComponentScan packages@Bean methodsEach BeanDefinition contains:
➡ Bean definitions = blueprints for creating beans.
Before any object is created, Spring runs BeanFactoryPostProcessors.
Examples:
ConfigurationClassPostProcessor (processes @Configuration)PropertySourcesPlaceholderConfigurer➡ These processors modify bean definitions before beans are instantiated.
Now Spring loads BeanPostProcessors — these run during bean creation.
Examples:
AutowiredAnnotationBeanPostProcessor (handles @Autowired)CommonAnnotationBeanPostProcessor (@PostConstruct, @PreDestroy)ApplicationContextAwareProcessor➡ These processors add behaviors around bean creation.
Spring now starts creating real Beans:
@PostConstructSingleton beans are created eagerly at startup (default).
➡ This is where your application’s objects actually come to life.
Spring performs several internal steps:
ApplicationListener beans➡ Now the container infrastructure is fully ready.
When running a web application:
DispatcherServlet is created➡ Your API endpoints become reachable at this step.
Spring completes the context initialization.
This triggers:
ContextRefreshedEventSmartLifecycle beans (Schedulers, Kafka, etc.)➡ ApplicationContext is now fully built.
Spring Boot fires:
ApplicationReadyEvent means:
➡ This is the final event before the application starts receiving requests.

ApplicationContext is more powerful than BeanFactory and provides many enterprise-level features.
Below are its most important features, explained clearly.
| Feature | Description |
|---|---|
| Dependency Injection (DI) | Automatically resolves and injects dependencies using constructor, setter, or field injection. Supports @Autowired, @Qualifier, @Primary. |
| Bean Lifecycle Management | Creates beans, performs dependency injection, calls lifecycle methods (@PostConstruct, @PreDestroy), applies BeanPostProcessor, and destroys beans gracefully. |
| Auto-Configuration Support | Automatically configures commonly used components based on classpath libraries, using Spring Boot’s auto-configuration mechanism. |
| AOP Integration | Creates proxies for aspects like @Transactional, @Async, @Cacheable, and custom AOP interceptors using JDK/CGLIB proxies. |
| Event Publishing System | Publishes and listens to framework-level and custom events such as ContextRefreshedEvent, ApplicationReadyEvent, etc. |
| Profile Management | Loads environment-specific beans and configurations using @Profile (e.g., dev, test, prod). |
| Environment & Property System | Reads and merges properties from application.properties, YAML files, system variables, and command-line arguments. |
| Resource Loading | Loads files and resources from classpath, filesystem, HTTP URLs, and JARs using Spring’s ResourceLoader. |
ApplicationContext is the core engine of Spring Boot. It is responsible for creating, managing, and wiring every component in the application. Without it, none of Spring Boot’s features would work.
It powers everything in Spring Boot, including:
@RestController, RequestMappings, JSON conversion)Without ApplicationContext → there is no Spring Framework behavior and no Spring Boot application.
It is the brain + backbone of the entire ecosystem.
ApplicationContext Architecture is the backbone of Spring Boot—it loads configurations, creates beans, manages dependencies, processes environment properties, handles events, and integrates with embedded servers to run the application smoothly.