Because in the persistence layer, business layer and control layer, @Repository, @Service and @Controller are used to stare at the classes in the hierarchy, while @Component is used to stare at the more neutral classes.
Extended data:
Pay attention to the principle of @component.
1, comment @ resource principle
1) Start the spring container and load the configuration file;
2) Objects will be created for two classes: students and people;
3) When it is resolved to
4) It will find out which bean properties have @Resource annotation within the scope of beans managed by spring;
(1) If the value of the name attribute of @Resource annotation is "",the name of the attribute where the annotation is located will be matched with the id of the bean in the spring container, and if the matching is successful, the object corresponding to the id will be assigned to the attribute; If the matching is unsuccessful, the matching is performed according to the type; If the re-matching is unsuccessful, an error is reported;
(2) If the value of the name attribute annotated by @Resource is not "",the value of the name attribute will be matched with the id of the bean in the spring container, and if the matching is successful, a value will be assigned; Otherwise, report the error directly.
Note: Comments can only be used for reference types.
Comments with @Resource (spring expansion package) and @ Autowired @ qualifiers have the same function.