Spring @Component, @Repository, @Service, @Controller

classes annotated with @Component, @Repository, @Service, @Controller are registered as Spring beans.

@Controller     用于控制层 
@Service        用于业务层
@Repository     用于数据访问层
@Component      描述Spring中的Bean,但它是一个泛化的概念,仅仅表示一个组件(Bean),可以作用在任何层次。
                如果一个 Bean 不知道属于哪个层,可以使用@Component 注解标注。

What is @Controller does?
What is @Service does?
What is @Repository does?
What is @Component does?

你可能感兴趣的:(框架,spring,java,spring,boot)