0

Can somebody explain what is happening behind the scene when we annotate class with @service and @component?

  • 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 Answers2

1

@Component creates a singleton bean of the class that are auto-detectable and auto-configurable classpath scanning.

  • 1
    quick 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
0

by default spring ApplicationContextContainer treat it as singleton here

venkey
  • 66
  • 6