The ApplicationContext
On This Lesson 4 topics
This lesson is planned. The outline below lists the topics it will cover. The full lesson has not been published yet.
In this lesson
explain what the container is and holds.
Planned topics
- The
ApplicationContextis the Spring container: it creates, wires, and keeps beans. - A bean is just an object the container manages.
- Startup: find bean definitions, create beans in dependency order, then the app is ready.
- You rarely touch the context directly; you ask for dependencies in constructors.
Draft outline details
Demonstration
ConfigurableApplicationContext ctx = SpringApplication.run(ShopApiApplication.class, args);
ProductService s = ctx.getBean(ProductService.class); // for the demo onlyCheck your understanding
Should services call getBean themselves?
Show answer
No. Declare the dependency in the constructor.
Practice
Apply this lesson with the module's lab, exercises and quiz.
Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.