bean scope

The rule for how many instances of a Spring bean exist: one shared singleton by default, or a new one per use, request or session.

In more detail

Because a singleton serves every request at once, storing request-specific data in its fields creates races and leaks data between callers. Keep singletons stateless, and choose another scope only when state ownership demands it. Scope is a design decision, not a performance switch.

Related terms

Taught in

References