@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项目都把以前学的那点框架知识忘光了,今天把以前做的一个项目翻出 ...
随机推荐
- (二)ECMA 335 解析 /ECMA 334
C#被ECMA组织,定义为了<ECMA334>标准化语言. 什么概念? 比如说,上一次成为ECMA标准的语言是Javascript.即<ECMA262>标准. <ECMA ...
- N种排序算法
本文根据<算法(第4版)>和<算法图解>整理.文中代码使用python编写. (一)选择排序 每次遍历整个数组,选出其中最小值.如果数组长度为n,则需要(n-1)+(n-2)+ ...
- 60天shell脚本计划-11/12-渐入佳境
--作者:飞翔的小胖猪 --创建时间:2021年3月18日 --修改时间:2021年3月22日 说明 每日上传更新一个shell脚本,周期为60天.如有需求的读者可根据自己实际情况选用合适的脚本,也可 ...
- WIN10:隐藏记事本等任务栏项目的最近访问
右键任务栏 点开任务栏设置 关闭最近打开项的显示按钮
- Python:list和ndarray的互相转化
a=np.arange(9).reshape(3,3) #a是一个3*3的array #array -> list l=a.tolist() [[0, 1, 2], [3, 4, 5], [6, ...
- JZ-027-字符串的排列
字符串的排列 题目描述 输入一个字符串,按字典序打印出该字符串中字符的所有排列.例如输入字符串abc,则按字典序打印出由字符a,b,c所能排列出来的所有字符串abc,acb,bac,bca,cab和c ...
- LeetCode-012-整数转罗马数字
整数转罗马数字 题目描述:罗马数字包含以下七种字符: I, V, X, L,C,D 和 M. 字符 数值 I 1 V 5 X 10 L 50 C 100 D 500 M 1000 例如, 罗马数字 2 ...
- 国产化之Arm64 CPU+银河麒麟系统安装.NetCore
背景 某个项目需要实现基础软件全部国产化,其中操作系统指定银河麒麟,银河麒麟就是一个Linux发行版,数据库使用达梦V8,这个数据库很多概念和Oracle相似,CPU平台的范围:龙芯.飞腾.鲲鹏等. ...
- Python中的os.environ系列的用法
>>> import os >>> os.environ.keys() ['LC_NUMERIC', 'GOPATH', 'GOROOT', 'GOBIN', 'L ...
- 彩色建模(四色原型) Object Modeling in Color学习心得
定义4种类的原型,在UML中用不同颜色表示不同原型的对象 1. Party, Place, Thing Party: 事件的参与方,例如某人人.某组织等 Place: 事件的发生地,例如仓库. ...