A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Spring default bean scope is singleton. why?
Pankaj Kr. Singh
Joined: Mar 31, 2011
Oct 11, 2013 23:15:40
As we know that the default a bean scope of bean in Spring framework is
So, why it is Singleton why not other like prototype etc.
Please help me...
Joined: Sep 06, 2009
Oct 12, 2013 01:52:56
Default scope is singleton to make sure that minimum number of objects are created during bean factory instantiation.
If single bean instance does not fit into specific scenario, user can choose to set beans scope as prototype.
Joined: Jul 28, 2003
Oct 14, 2013 23:21:34
Agree with Salil's answer. That is the advantage of Spring. There is difference between Spring's singleton and Java singleton object.
It creates very less amount of objects in memory.
OCAJP Mock Questions
400+ OCPJP Mock Questions
subject: Spring default bean scope is singleton. why?
Injection - instance variable
Spring - singleton attribute not available when using namespace
Instantiating a Bean in Spring
injection and lookup
Information about Design Patterns used by Spring.
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014