Wednesday, January 2, 2019

Use of @Scope annotation with Spring Controller

1) Is it compulsory to use @Scope attribute?
No. If you want the default ("singleton") then you don't need to specify.
2) What if we do not use?
Then your application will only create one instance of the bean.
3) Is it good practice to use @Scope with @Controller?
No. It does not make sense for an application to have more than one instance of a controller class (or a repository). If you have a need to use both annotations together, then you are not modelling your classes very well.

No comments:

Post a Comment

Spring Annotations