What bean scopes does Spring support? Explain them

Three of the five scopes supported by the Spring Framework are only available if users utilize a web-aware ApplicationContext.

  • Singleton: This scopes the bean definition to a single instance per Spring IoC container.
  • Prototype: This scopes a single bean definition to have any number of object instances.
  • Request: This scopes a bean definition to an HTTP request, only valid in the context of a web-aware Spring ApplicationContext.
  • Session: This scopes a bean definition to an HTTP session, only valid in the context of a web-aware Spring ApplicationContext.
  • Global-session: This scopes a bean definition to a global HTTP session, only valid in the context of a web-aware Spring ApplicationContext.