Tuesday, August 18, 2020

Spring Bean Scope

 Spring Bean Scopes:

There are different types of Bean Scopes which spring provides.

The commonly used and default bean scope in spring is SINGLETON bean scope.

if no bean scope is specifically defined, spring uses sigleton bean scope. i.e. we get one instance per context of any bean.


Types of Bean Scope:

1. Sigleton Scope:

    We get to instantiate only once.

2. Prototype Scope:

    A new instance every time it is referenced. The instance is made available for garbage collection once it it no longer needed for reference.

This scope is useful for transient data or flex based application state

3. Session Scope:

    one instance of bean per user session.

    only available for web applications.

4. Request scope:

    one instance per request in the application

    only available for web applications.

    

No comments:

Post a Comment

Spring - AutoWiring

Spring automatically resolves the dependencies between the collaborating beans by inspecting the contents of the BeanFactory. This is called...