wood burning stoves 2.0*
The moose likes Spring and the fly likes Spring default bean scope is singleton. why? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Spring default bean scope is singleton. why?" Watch "Spring default bean scope is singleton. why?" New topic

Spring default bean scope is singleton. why?

Pankaj Kr. Singh
Ranch Hand

Joined: Mar 31, 2011
Posts: 32

Hi All,

As we know that the default a bean scope of bean in Spring framework is Singleton.
So, why it is Singleton why not other like prototype etc.
Please help me...

Salil Vverma
Ranch Hand

Joined: Sep 06, 2009
Posts: 253

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.

Salil Verma
Krishna Srinivasan
Ranch Hand

Joined: Jul 28, 2003
Posts: 1844

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.

Krishna Srinivasan
Spring Tutorials, OCAJP Mock Questions, 400+ OCPJP Mock Questions
I agree. Here's the link: http://aspose.com/file-tools
subject: Spring default bean scope is singleton. why?
Similar Threads
injection and lookup
Injection - instance variable
Instantiating a Bean in Spring
Spring - singleton attribute not available when using namespace
Information about Design Patterns used by Spring.