We can choose to proclaim an extension for a bean while defining it. For instance, if we constrain Spring to deliver another bean occasion each time, we can initialize a prototype scope as an attribute of a bean. Additionally, if we need Spring to restore a similar bean example, we should proclaim the bean's scope attribute to be a singleton.
Spring Framework underpins the accompanying five scopes, three of which are accessible in the event that we utilize a web-aware ApplicationContext. Here are some common scopes:
- Singleton: Returns the same instance that's used by default every time
- Prototype: Returns a different instance every time
- Request: Defines an HTTP request that's visible in a single JSP page of the application
- Session: Defines an HTTP session that's visible in all JSP pages of the application