*
The moose likes Spring and the fly likes Does Spring treat the @Service as a Singleton? 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 "Does Spring treat the @Service as a Singleton?" Watch "Does Spring treat the @Service as a Singleton?" New topic
Author

Does Spring treat the @Service as a Singleton?

Sam Yim
Greenhorn

Joined: Jul 25, 2009
Posts: 17
If I have a class that is annotated with @Service, Spring create one instance of this to be shared in the JVM?

Or will every consumer class that autowires the service will get a new instance of the service?
Jayesh A Lalwani
Bartender

Joined: Jan 17, 2008
Posts: 2280
    
  28

By default Service annotation creates a singleton scoped bean. If you want to change the behavior, you have to annotate with @Scope
Sam Yim
Greenhorn

Joined: Jul 25, 2009
Posts: 17
Great. That was the expected behavior I hoped for. Thanks for the response.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Does Spring treat the @Service as a Singleton?
 
Similar Threads
Doubts about Dependency Injection
how to deploy jmetter in jboss
JaxWs Support in Spring?
New to Spring and New to Web Services.
Session swapping problem under load