@Component@Service@Controller@Repository是spring注解,注解后可以被spring框架所扫描并注入到spring容器来进行管理 
@Component是通用注解,其他三个注解是这个注解的拓展,并且具有了特定的功能 
@Repository注解在持久层中,具有将数据库操作抛出的原生异常翻译转化为spring的持久层异常的功能。 
@Controller层是spring-mvc的注解,具有将请求进行转发,重定向的功能。 
@Service层是业务逻辑层注解,这个注解只是标注该类处于业务逻辑层。 
用这些注解对应用进行分层之后,就能将请求处理,义务逻辑处理,数据库操作处理分离出来,为代码解耦,也方便了以后项目的维护和开发。

@Component, @Service, @Controller, @Repository区别的更多相关文章

  1. (转载)Spring 注解@Component,@Service,@Controller,@Repository

    Spring 2.5 中除了提供 @Component 注释外,还定义了几个拥有特殊语义的注释,它们分别是:@Repository.@Service 和 @Controller.在目前的 Spring ...

  2. Spring 注解@Component,@Service,@Controller,@Repository

    Spring 注解@Component,@Service,@Controller,@RepositorySpring 2.5 中除了提供 @Component 注释外,还定义了几个拥有特殊语义的注释, ...

  3. Rhythmk 一步一步学 JAVA (14) Spring-3 @Autowired,@Qualifier @Required @Resource @Component,@Service,@Controller,@Repository @PostConstruct,@PreDestroy

    1.@Autowired 注解:首先在使用时候需要引入配置: <!-- 该 BeanPostProcessor 将自动起作用,对标注 @Autowired 的 Bean 进行自动注入 --> ...

  4. @Component,@Service,@Controller,@Repository

    1.@controller 控制器(注入服务) 2.@service 服务(注入dao) 3.@repository dao(实现dao访问) 4.@component (把普通pojo实例化到spr ...

  5. Spring中的注解@Service @Component @Controller @Repository区别

    @Service用于标注业务层组件, @Controller用于标注控制层组件(如struts中的action), @Repository用于标注数据访问组件,即DAO组件, @Component泛指 ...

  6. @Component, @Repository, @Service,@Controller的区别

    @Component, @Service, @Controller, @Repository是spring注解,注解后可以被spring框架所扫描并注入到spring容器来进行管理 @Componen ...

  7. Spring注解的使用和区别:@Component、@Service、@Repository、@Controller

    Spring 2.5 中除了提供 @Component 注释外,还定义了几个拥有特殊语义的注释,它们分别是:@Repository.@Service 和 @Controller.在目前的 Spring ...

  8. @Component注解、@Service注解、@Repository注解、@Controller注解区别

    --------------------------------------------------------------------------------------------------- ...

  9. Spring注解之@Component、@Controller、@Service、@Repository

    目录 1.使用这四个注解的前提 2.详解@Component 3. @Service("XXX")或者@Service(value = "XXX")情况 4.总 ...

随机推荐

  1. 使用docker运行springboot项目

    本文主要讲的是使用docker运行springboot项目 获取一个springboot项目 这里我没有重新构建,用的之前写的一个项目,直接从github上下载下来,地址:https://github ...

  2. ssm-restful风格

    码云 https://gitee.com/MarkPolaris/ssm-test02

  3. golang--redis连接池

    通过golang对redis操作,还可以通过redis连接池,流程如下: (1)事先初始化一定数量的连接,投入到连接池: (2)当go需要操作redis时,直接从连接池取出连接即可: (3)这样可以节 ...

  4. spring cloud 2.x版本 Gateway动态路由教程

    摘要 本文采用的Spring cloud为2.1.8RELEASE,version=Greenwich.SR3 本文基于前面的几篇Spring cloud Gateway文章的实现. 参考 Gatew ...

  5. Unity TextMeshPro 一键生成工具

    本文参考了这片博客文章,在此基础上进行优化和改进: https://blog.csdn.net/akof1314/article/details/80868869 先截张效果图: TextMeshPr ...

  6. java高并发系列 - 第7天:volatile与Java内存模型

    public class Demo09 { public static boolean flag = true; public static class T1 extends Thread { pub ...

  7. 死磕 java同步系列之CountDownLatch源码解析

  8. .net 通过反射实现两个相同结构实体类的转换

    public static T2 CopyToModel<T1, T2>(T1 source) { T2 model = default(T2); PropertyInfo[] pi = ...

  9. centos 7 搭建Samba

    一.Samba简介 Samba是一个能让Linux系统应用Microsoft网络通讯协议的软件,由客户端和服务端构成. SMB(Server Message Block的缩写,即服务器消息块)主要是作 ...

  10. git fetch & pull详解

    1.简单概括 先用一张图来理一下git fetch和git pull的概念: 可以简单的概括为: git fetch是将远程主机的最新内容拉到本地,用户在检查了以后决定是否合并到工作本机分支中. 而g ...