| 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: 1321
|
|
|
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.
|
 |
 |
|
|
subject: Does Spring treat the @Service as a Singleton?
|
|
|