@Scope – How to get Scope of Bean from Code
When we create a Bean we are creating actual instances of the class defined by that bean definition. We can also control the scope of the objects created from a particular bean definition.
There are 5 types of scopes in bean,
- singleton (default scope)
Single instance per spring IoC container
Single bean definition to any number of object instances.
Bean definition for each request. Only valid web-aware Spring ApplicationContext.
Bean definition for a session. Only valid web-aware Spring ApplicationContext.
Similar to session but the only makes sense in the context of portlet-based web applications. Only valid web-aware Spring ApplicationContext.