beginnerBeans, Configuration & Lifecycle

What is the default bean scope in Spring, and when would you use `prototype` instead?

The default scope is `singleton` — exactly one instance per Spring container, shared by every injection point. `prototype` creates a brand-new instance every time the bean is requested, which matters for stateful, non-thread-safe objects (e.g. a mutable builder-like helper) where sharing one instance across concurrent requests would cause data races.

This is a Pro chapter

Sign in, then upgrade to Pro or Power to unlock this and the full Spring Ecosystem Mastery library.

What is the default bean scope in Spring, and when would you use `prototype` instead?

Next Step

Continue to What's the correct way to run code right after a bean's dependencies are injected?← Back to all Spring Boot questions