Repaso
EspaƱol

What is the default scope of a Spring bean?

Options

  1. Prototype: a new instance on every injection
  2. Singleton: one shared instance per application context (Correct option)
  3. Request: one instance for each HTTP request
  4. Session: one instance for each logged-in user

Answer

Singleton: one shared instance per application context

Why

By default Spring creates ONE instance of each bean and shares it everywhere (singleton scope; not the GoF pattern, but one per container).

Because many threads use the same object, singleton beans should be stateless: avoid mutable fields that change per request.

Other scopes exist (prototype, request, session) but are rarely needed.

Remember

Beans are singletons by default, so keep them stateless.

Key terms

Practice this question in Repaso