Spring Bean Scopes Explained
A Scope defines how long a bean lives and how many instances Spring creates.
| Scope | How Many Instances? | Best Used For |
|---|---|---|
| Singleton (Default) | Exactly 1 shared instance per application | Services, Repositories, Controllers (Stateless classes) |
| Prototype | A NEW instance every time requested | Stateful objects holding unique data per request |
| Request (Web) | 1 instance per HTTP Request | User Request tracking context |
| Session (Web) | 1 instance per User HTTP Session | User Shopping Cart, Login Session |