Bean scopes
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
pick singleton or prototype.
Planned topics
- Singleton (default): one shared instance per container.
- Prototype: a new instance each time it is requested.
- Web scopes (request, session) exist; use them rarely.
- Almost all Shop beans are singletons.
- A prototype injected into a singleton is created only once, at injection time.
Draft outline details
Demonstration
@Component @Scope("prototype") class ReportBuilder {}Check your understanding
What is the default scope?
Show answer
Singleton.
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.