How many types of spring beans scope are there?

There are 5 type of spring beans scope.

1)Singleton:- Singleton is a bean where only one instance will be created as per entire IOC container and same instance will be injected wherever will required.it is default scope. If our bean class is stateless then use singleton. as controllers, DaoImpl class.
 
2)Prototype:-if we configure prototype then multiple instances of bean will be created and injected wherever required. if they have state then use prototype scope.
 
3)Request: request scope is where a new bean instance will be created for every http request.
 
4)Session: session scope is where only one bean instance will be used across the session.
 
5)Global session:-it use only when instance will be portlets within our application. Same bean will be used across this global session portlets.

Note:If we are not specify any scope in bean configuration file.then it will be take by default singleton bean scope.
can we inject prototype bean into singleton, yes at run time prototype bean use in singleton bean.

How many types of spring beans scope are there? Read More »