@Component、@Service、@Constroller,@Repository,它们分别用于软件系统的不同层次:

  • @Component 是一个泛化的概念,仅仅表示一个组件 (Bean) ,可以作用在任何层次。
  • @Service 通常作用在业务层,但是目前该功能与 @Component 相同。
  • @Constroller 通常作用在控制层,但是目前该功能与 @Component 相同
  • @Repository通常用于将数据访问层 (DAO 层 ) 的类标识为 Spring Bean

为了让 Spring 能够扫描类路径中的类并识别出 @Repository 注解,需要在 XML 配置文件中启用Bean 的自动扫描功能,这可以通过<context:component-scan/>实现

<beans … >
……
<context:component-scan base-package=”bookstore.dao” />
  ……
</beans>

@Component、@Service、@Constroller的更多相关文章

  1. Spring注解详解@Repository、@Component、@Service 和 @Constroller

    概述 注释配置相对于 XML 配置具有很多的优势: 它可以充分利用 Java 的反射机制获取类结构信息,这些信息可以有效减少配置的工作.如使用 JPA 注释配置 ORM 映射时,我们就不需要指定 PO ...

  2. @Repository、@Service、@Controller 和 @Component

    转载:http://blog.csdn.net/ye1992/article/details/19971467 spring 自 2.0 版本开始,陆续引入了一些注解用于简化 Spring 的开发.@ ...

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

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

  4. Spring注解@Repository、@Service、@Controller、@Component

    继前几章所讲解的注解中: http://www.cnblogs.com/EasonJim/p/6892280.html http://www.cnblogs.com/EasonJim/p/689974 ...

  5. [转] Spring注解@Component、@Repository、@Service、@Controller区别

    原文地址:http://blog.csdn.net/zhang854429783/article/details/6785574 很长时间没做web项目都把以前学的那点框架知识忘光了,今天把以前做的一 ...

  6. 【转】Spring注解@Component、@Repository、@Service、@Controller区别

    http://blog.csdn.net/zhang854429783/article/details/6785574 很长时间没做web项目都把以前学的那点框架知识忘光了,今天把以前做的一个项目翻出 ...

  7. Spring @Autowired、@Resource、@Required、@Component、@Repository、@Service、@Controller注解的用法和作用

    Spring @Autowired,@Resource,@Required注解的用法和作用 Spring中 @Autowired标签与 @Resource标签 的区别 Spring注解@Compone ...

  8. Spring注解 @Component、@Repository、@Service、@Controller @Resource、@Autowired、@Qualifier 解析

    @Repository.@Service.@Controller 这几个是一个类型,其实@Component 跟他们也是一个类型的 Spring 2.5 中除了提供 @Component 注释外,还定 ...

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

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

随机推荐

  1. Python 线程调用

    简介: Python 线程可以通过主线程,调用线程来执行其他命令, 为Python提供更方便的使用. 并发线程测试 # 命令调用方式 import threading,time # 定义每个线程要运行 ...

  2. Charles手机端抓包--证书

    应用测试: Charles通过无线对手机进行抓包 测试系统: ubuntu 16.04 LTS 测试手机: IOS 10.3(14E277) Charles版本: Charles 4.1.4 手机证书 ...

  3. poj 2369 Permutations - 数论

    We remind that the permutation of some final set is a one-to-one mapping of the set onto itself. Les ...

  4. Python3基础 list 元组转成列表

             Python : 3.7.0          OS : Ubuntu 18.04.1 LTS         IDE : PyCharm 2018.2.4       Conda ...

  5. 打开vi后提示The ycmd server SHUT DOWN (restart with :YcmRestartServer)该如何处理

    答:进入YouCompleteMe的安装目录安装一些必要的依赖 比如:笔者将YouCompleteMe安装到了~/.vim/bundle目录下,那么执行以下操作: cd ~/.vim/bundle/Y ...

  6. JavaScript callee caller

    caller是function的属性 callee是arguments的属性 callee:返回正在执行的函数对象. var sum = function (n) { == n) ; ); } con ...

  7. Shell变量知识进阶

    一,Shell中特殊且重要的变量 $0结合dirname和basename分别取出脚本名称和脚本路径 [root@192-168-3-163 scripts]# cat test.sh #!/bin/ ...

  8. 【第二十五章】 springboot + hystrixdashboard

    注意: hystrix基本使用:第十九章 springboot + hystrix(1) hystrix计数原理:附6 hystrix metrics and monitor 一.hystrixdas ...

  9. 【第十八章】 springboot + thymeleaf

    代码结构: 1.ThymeleafController package com.xxx.firstboot.web; import org.springframework.stereotype.Con ...

  10. java 类构造器中加入有参构造器及调用顺序【思路】

    package com.ykmimi.new1; /** * * @author deadzq * */ public class AnyThing { public AnyThing() { thi ...