The scope of the objects created from a particular bean definition can be defined. This gives the flexibility to choose the scope of the objects you create.

Spring Framework supports five scopes:

  • Singleton: Only 1 instance of Bean will be there.
  • Prototype: When Bean is called a new Instance will be created.
  • Request: Single bean definition to the lifecycle of a single HTTP request; means every HTTP request will have its own instance of a bean created off the back of a single bean definition.
  • ApplicationContext: Session Scopes a single bean definition to the lifecycle of a HTTP Session.
  • Global session: Scopes a single bean definition to the lifecycle of a Global HTTP Session. Typically only valid when used in a port let context. Only valid for the context of web-aware Spring.