Can somebody explain what is happening behind the scene when we annotate class with @service and @component?
Asked
Active
Viewed 791 times
0
-
This might help https://stackoverflow.com/questions/51630951/what-is-the-difference-between-bean-annotation-and-component-annotation-at-spr/51632948#51632948 – MyTwoCents Dec 26 '19 at 05:29
2 Answers
1
@Component creates a singleton bean of the class that are auto-detectable and auto-configurable classpath scanning.

Shubham Srivastava
- 95
- 5
-
1quick question. Even @service is auto detectable right? what is the default scope of @service? – Karki Sundaram Dec 27 '19 at 04:36
-
Yes, 1)Service is also auto-detectable as long as component scanning is enabled in the package in which the service class is present. 2)Scope of Service is singleton. 3) The Component and Service annotations are the same, the only difference is that Service is used to make business logic implementation class detectable, while Component is a generic annotation to make any class detectable. – Shubham Srivastava Dec 27 '19 at 14:46