@Component, @Controller, @Repository, @Service 有何区别?
@Component :这将 java 类标记为 bean。它是任何 Spring 管理组件的通
用构造型。spring 的组件扫描机制现在可以将其拾取并将其拉入应用程序环境
中。
@Controller :这将一个类标记为 Spring Web MVC 控制器。标有它的
Bean 会自动导入到 IoC 容器中。
@Service :此注解是组件注解的特化。它不
会对 @Component 注解提供任何其他行为。您可以在服务层类中使用
@Service 而不是 @Component,因为它以更好的方式指定了意图。
@Repository :这个注解是具有类似用途和功能的 @Component 注解的特
化。它为 DAO 提供了额外的好处。它将 DAO 导入 IoC 容器,并使未经检查
的异常有资格转换为 Spring DataAccessException。
@Component, @Controller, @Repository, @Service 有何区别?的更多相关文章
- 关于Spring注解 @Service @Component @Controller @Repository 用法
@Component 相当于实例化类的对象,其他三个注解可以理解为@Component的子注解或细化. 在annotaion配置注解中用@Component来表示一个通用注释用于说明一个类是一个spr ...
- Spring中的注解@Service @Component @Controller @Repository区别
@Service用于标注业务层组件, @Controller用于标注控制层组件(如struts中的action), @Repository用于标注数据访问组件,即DAO组件, @Component泛指 ...
- SpringMVC注解@Component、@Repository、@Service、@Controller区别
SpringMVC中四个基本注解: @Component.@Repository @Service.@Controller 看字面含义,很容易却别出其中三个: @Controller 控制层, ...
- [转]what’s the difference between @Component ,@Repository & @Service annotations in Spring
原文地址:https://www.cnblogs.com/softidea/p/6070314.html @Component is equivalent to <bean> @Servi ...
- What's the difference between @Component, @Repository & @Service annotations in Spring?
@Component is equivalent to <bean> @Service, @Controller , @Repository = {@Component + some mo ...
- [转] Spring注解@Component、@Repository、@Service、@Controller区别
原文地址:http://blog.csdn.net/zhang854429783/article/details/6785574 很长时间没做web项目都把以前学的那点框架知识忘光了,今天把以前做的一 ...
- @Component @Repository @Service @Controller
Spring 2.5 中除了提供 @Component 注释外,还定义了几个拥有特殊语义的注释,它们分别是:@Repository.@Service 和 @Controller.在目前的 Spring ...
- Spring注解@Component、@Repository、@Service、@Controller,@Autowired、@Resource用法
一.Spring定义bean,@Component.@Repository.@Service 和 @Controller Spring 2.5 中除了提供 @Component 注释外,还定义了几个拥 ...
- 【转】Spring注解@Component、@Repository、@Service、@Controller区别
http://blog.csdn.net/zhang854429783/article/details/6785574 很长时间没做web项目都把以前学的那点框架知识忘光了,今天把以前做的一个项目翻出 ...
随机推荐
- 大数据BI系统是怎么助力企业长久发展的
多元化集团企业在发展到一定阶段后,往往会遇到业务与财务分离.管理缺乏系统决策支持等管理问题.财务决策支持系统建设实施BI是管理升级的内在要求. 1996年,加特纳集团提出了商业智能(Businesin ...
- 【C# GC】C# GC何时被调用
首先要指导GC的机制,这部分转载自:http://blog.csdn.net/qq_20949153/article/details/52188882CLR:公共运行时环境,管理托管堆.CTR:设置引 ...
- C# 使用NPOI处理Excel模板-【前面部分固定,中间是动态的几行,尾部是固定的部分】
今天同组的兄弟问我,他有一个导出的模板,大概如下: [前面部分固定,中间是动态的几行,尾部是固定的部分].其实这个很像单链表往单链表在指定插入数据. 他问我怎么做才好,他想到的做法是:因为这些动态列的 ...
- visual studio 快捷键重置及设置
https://blog.csdn.net/glw0223/article/details/93195009
- P1424
#include <stdio.h> int main(){ int s = 250; int x, n, distance = 0; scanf("%d %d",&a ...
- WPF中Enter 焦点转移方法
1.Set the TabIndex="16"2. private void detailGrid_Keydown(object sender, KeyEventArgs e) { ...
- Golang 基础之基础语法梳理 (三)
大家好,今天将梳理出的 Go语言基础语法内容,分享给大家. 请多多指教,谢谢. 本次<Go语言基础语法内容>共分为三个章节,本文为第三章节 Golang 基础之基础语法梳理 (一) Gol ...
- Java程序员必备的工具和框架
最近几年,Java 的技术栈发展的非常快,成百上千的技术工具正不断地涌出来,这也造成了一个问题: 我们作为开发者,到底应该选哪些工具搭建出最合适的技术栈呢? 今天我就推荐一波我常用的.我了解的工具和框 ...
- 4月2日 python学习总结
昨天内容回顾: 1.迭代器 可迭代对象: 只要内置有__iter__方法的都是可迭代的对象 既有__iter__,又有__next__方法 调用__iter__方法==>得到内置的迭代器对象 调 ...
- 一键生成mapper、mapperxml等文件——MybatisX插件的使用
本文首发于西二blogs:一键生成mapper.mapperxml等文件--MybatisX插件的使用 搬运请务必转载出处. MybatisX插件使用--为快速开发而生 前言:其实很久以前我就非常厌恶 ...