File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
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: 2052
    
  22

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
Session swapping problem under load
Doubts about Dependency Injection
New to Spring and New to Web Services.
JaxWs Support in Spring?
how to deploy jmetter in jboss