Spring中@Component, @Controller, @Service, @Repository注解的区别说明?
下文笔者讲述Spring中@Component, @Controller, @Service, @Repository注解的区别说明,如下所示
@Component, @Controller, @Service, @Repository注解的功能
用于标识类
将类标识为spring bean,并标注为不同的组件
@Component, @Controller, @Service, @Repository注解的简介
@Controller:
用于标注控制层组件
@Service:
用于标注业务层组件
@Repository:
用于标注数据访问层组件,即DAO组件
@Component:
组件
当我们不知道组件的分类时,此时我们可使用此注解进行标注
版权声明
本文仅代表作者观点,不代表本站立场。
本文系作者授权发表,未经许可,不得转载。


