6.SpringBoot : scope of spring bean | Interview Question

Опубликовано: 13 Март 2026
на канале: Pavan Tricks
7
1

Scope of spring bean: 6 scopes



Singleton (default):

This is the default scope in Spring. A single instance of the bean is created and shared across the entire application context.



Prototype:

A new instance of the bean is created every time it is requested from the container.



Request:

A new instance of the bean is created for each HTTP request in a web application.



Session:

A new instance of the bean is created for each HTTP session in a web application.



Application:

A single instance of the bean is shared across all requests in a web application's lifecycle.



WebSocket:

A new instance of the bean is created for each WebSocket connection in a web application.