用Spring MVC时@Controller注解的类将变成一个Spring MVC的控制器. 
不用Spring MVC的情况下, 这四个注解没有区别.
根据注解的语义, 注解在类上面可以提高代码的可读性.
@Repository代表仓库. 一般注解在DAO实现类上, 别人看代码时, 就知道这个类是一个跟数据存储有关的类.
@Service代表业务. 一般注解在Service实现类上.
@Controller代表控制器. 一般注解在控制器类上.
如果你的类不是以上类型(数据存储类, 业务类, 控制器), 可以笼统的使用@Component

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

  1. SpringAnnotation注解之@Component,@Repository,@Service,@Controller

    @Component:组件,表示此写上了此注解的bean,作为一个组件存在于容器中.这样的话别的地方就可以使用@Resource这个注解来把这个组件作为一个资源来使用了.初始化bean的名字为类名首字 ...

  2. @Component @Repository @Service @Controller

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

  3. Spring-Boot-Bean的使用,@Repository,@Service,@Controller,@Component

    前言 在Spring MVC的时候,我们使用xml来配置bean,如今的Spring boot推荐我们使用元注解的发生,那就听Spring Boot的推荐,下面我就为大家来介绍下Spring Boot ...

  4. 从头认识Spring-2.7 自己主动检測Bean(1)-@Component @Repository @Service @Controller

    这一章节我们来讨论一下自己主动检測Bean. 1.domain 厨师类: package com.raylee.my_new_spring.my_new_spring.ch02.topic_1_19; ...

  5. 【转载】@Component, @Repository, @Service的区别

    @Component, @Repository, @Service的区别 官网引用 引用spring的官方文档中的一段描述: 在Spring2.0之前的版本中,@Repository注解可以标记在任何 ...

  6. @Service ,@Controller,@Component注解

    首先,在applicationContext.xml文件中加一行: <context:component-scan base-package="com.hzhi.clas"/ ...

  7. 使用Spring的@Autowired 实现DAO, Service, Controller三层的注入(转)

    简述: 结合Spring和Hibernate进行开发 使用@Autowired实现依赖注入, 实现一个学生注册的功能,做一个技术原型 从DAO(Repository) -> Service -& ...

  8. @Repository、@Service、@Controller 和 @Component(转)

    鸣谢:http://blog.csdn.net/ye1992/article/details/19971467 @Repository.@Service.@Controller 和 @Componen ...

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

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

随机推荐

  1. 【Reporting Services 报表开发】— 怎么根据当前表单的guid作为参数查询相关数据?

    select AId from FilteredA as CRMAF_FilteredA 用这个 作为一个DataSet1 , 然后添加在报表里面添加一个参数 @AId,设置的默认的查询为前面Data ...

  2. <dedecms>织梦内页调用会员信息

    1.织梦CMS v5.7调用文章所属会员信息标签 打开官方默认模板article_artcile.htm,我们可以提取出如下代码:  {dede:memberinfos}   会员头像:<a h ...

  3. iotBaidu问题小结

    1.后台程序不能正常运行: d:\>java -jar MqttService.jar Exception in thread "main" java.lang.Securi ...

  4. python 笔记 2017

    26.反斜杠用处,断言一些字符包含特殊字符的 if "<h3 class=\"entH 22222setH\">刷新成功</h3>" i ...

  5. eclipse JDK 下载 and 安装 and 环境配置

    eclipse和JDK软件下载 链接:https://pan.baidu.com/s/1bpRHVIhNtK9_FMVbi34YUQ 密码:y3xr eclipse和JDK这两个软件是配套使用的,适用 ...

  6. linux中uptime命令查看linux系统负载

    阅读目录 uptime cat /proc/loadavg 何为系统负载呢? 进阶参考 uptime 另外还有一个参数 -V(大写),是用来查询版本的 [appdeploy@CNSZ22PL0088: ...

  7. R语言学习——欧拉计划(1)Multiples of 3 and 5

    [题目一]If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. ...

  8. shell 4注释

    单行注释 每一行加一个#号. #shell #!/bin/sh echo "#" #轻轻的我走了 #正如我轻轻的来 #我挥一挥衣袖 #不带走一片云彩 echo "#&qu ...

  9. EL中拼接字符串的方法

    近期在项目中碰到一个需要在JSP页面中比较两String类型的值的问题,于是想当然的写了如下代码: <c:if test="${'p'+longValue=='p1'}"&g ...

  10. solr6.3根据搜索关键词词频(关键词出现次数、关键词highlight)进行排序

    http://localhost:8080/solr/test/select?fq=product_name:大有&indent=on&q=product_name:大有电钻 OR r ...