@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. nodejs+Express中使用mustache模板引擎

    由于公司一个seo项目,需要我协助.此项目他人已经开发大半,由于seo需要,使用了服务器端模板引擎.我项目的后端同事说项目是go语音写的,跑项目麻烦,只给了我template和css等静态文件. 为了 ...

  2. P3525 INS-Inspection

    这道题的题面有点问题,如果按照题面做,应该是A不了的,下面引用一下评论里@REM_001的翻译 一棵n个节点的树,行动中心S从1->N.从S出发前往任意一个未标记到的点(沿树上两点的唯一路径走) ...

  3. TensorFlow2.0教程-使用keras训练模型

    1.一般的模型构造.训练.测试流程 # 模型构造 inputs = keras.Input(shape=(784,), name='mnist_input') h1 = layers.Dense(64 ...

  4. ubuntu 18.04 安装mysql 遇到语言格式不兼容性问题解决

    安装mysql的时候,遇到了这样一个错误:perl: warning: Setting locale failed. perl: warning: Please check that your loc ...

  5. 解决 layui 弹出层(弹框)一闪而过就消失的问题 (转载)

    转载: 原文链接:https://blog.csdn.net/qq_20594019/article/details/83956532 本人遇到问题:使用layer.open()弹出页面层,出现弹框闪 ...

  6. centos 8 docker-ce 安装

    https://www.techrepublic.com/article/a-better-way-to-install-docker-on-centos-8/ https://linuxconfig ...

  7. SpringBoot(16)—@ConditionalOnBean与@ConditionalOnClass

    @ConditionalOnBean与@ConditionalOnClass 上一篇讲的@Conditional可以通过条件控制是否注入Bean,这篇讲下有关Bean其它几个常用的注解使用方式 @Co ...

  8. ES6变量的解构赋值(二)对象的解构赋值

    前面我们知道,数组的结构赋值需要按顺序进行赋值, let [a,,c] = [,,] console.log(a); console.log(c);//3 let [a,b] = [1];consol ...

  9. CSS 2D 转换

    通过CSS 2D转换,我们能够对元素进行移动.缩放.转动.拉长或拉伸. 2D转换一共五个属性:transfrom=> translate(X轴数值px,Y轴数值px):元素从其当前位置移动,根据 ...

  10. CVE-2019-0708-BlueKeep漏洞复现

    环境 攻击机:Kali Linux IP:192.168.0.108 靶机:Windows Sever 7 SP1 旗舰版 IP:192.168.0.109 Exploit: https://gith ...