@Component、@Service、@Constroller
2015-09-13 22:50
211 查看
@Component、@Service、@Constroller,@Repository,它们分别用于软件系统的不同层次:
@Component 是一个泛化的概念,仅仅表示一个组件 (Bean) ,可以作用在任何层次。
@Service 通常作用在业务层,但是目前该功能与 @Component 相同。
@Constroller 通常作用在控制层,但是目前该功能与 @Component 相同
@Repository通常用于将数据访问层 (DAO 层 ) 的类标识为 Spring Bean
为了让 Spring 能够扫描类路径中的类并识别出 @Repository 注解,需要在 XML 配置文件中启用Bean 的自动扫描功能,这可以通过<context:component-scan/>实现
@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>
相关文章推荐
- 表单操作
- Neutron 理解 (4): Neutron OVS OpenFlow 流表 和 L2 Population [Netruon OVS OpenFlow tables + L2 Populatio
- Android核心基础-9.Android四大组件之BroadcastReceiver
- 树莓派重新启动和复位的方法
- 安装LuaSocket
- 模拟登录-知乎
- LeetCode Problem:Reverse Integer
- 模板模式
- 二叉查找树的创建,查找,删除,插入的c描述
- java-RAC Oracle 连接字符串
- 软件管理器简介
- Sublime Text2使用教程
- Git - Permission denied (publickey)
- LintCode Flip Bits
- docker常用命令
- Linux下可执行文件格式详解
- 05字符串格式化符号含义以及转义符号含义
- XFire发布Web Services
- 苹果开发者帐号三种类型的区别
- Sublime Text2使用教程