当前位置:网站首页>@controller,@service,@repository,@component区别
@controller,@service,@repository,@component区别
2022-07-06 09:12:00 【程序员柒七】
1、@controller 控制器(注入服务、用在Controller层)
用于标注控制层,相当于struts中的action层
2、@service 服务(注入dao、用在Service层)
用于标注服务层,主要用来进行业务的逻辑处理
3、@repository(实现dao访问、用在Mapper层)
用于标注数据访问层,也可以说用于标注数据访问组件,即DAO组件.
4、@component (把普通pojo实例化到spring容器中,相当于配置文件中的 )
泛指各种组件,就是说当我们的类不属于各种归类的时候(不属于@Controller、@Services等的时候),我们就可以使用@Component来标注这个类。
说明:
<context:component-scan base-package=”com.*”>
上面的这个例子是引入Component组件的例子,其中base-package表示为需要扫描的所有子包。
共同点:被@controller 、@service、@repository 、@component 注解的类,都会把这些类纳入进spring容器中进行管理
边栏推荐
- Win10: how to modify the priority of dual network cards?
- MySQL實戰優化高手04 借著更新語句在InnoDB存儲引擎中的執行流程,聊聊binlog是什麼?
- 第一篇博客
- Ueeditor internationalization configuration, supporting Chinese and English switching
- API learning of OpenGL (2003) gl_ TEXTURE_ WRAP_ S GL_ TEXTURE_ WRAP_ T
- 软件测试工程师发展规划路线
- Mysql24 index data structure
- Yum prompt another app is currently holding the yum lock; waiting for it to exit...
- UEditor国际化配置,支持中英文切换
- Mysql30 transaction Basics
猜你喜欢

Bytetrack: multi object tracking by associating every detection box paper reading notes ()

MySQL transaction log

ByteTrack: Multi-Object Tracking by Associating Every Detection Box 论文阅读笔记()

API learning of OpenGL (2003) gl_ TEXTURE_ WRAP_ S GL_ TEXTURE_ WRAP_ T

MySQL33-多版本并发控制

软件测试工程师必备之软技能:结构化思维

CSDN-NLP:基于技能树和弱监督学习的博文难度等级分类 (一)

MySQL實戰優化高手04 借著更新語句在InnoDB存儲引擎中的執行流程,聊聊binlog是什麼?

Valentine's Day is coming, are you still worried about eating dog food? Teach you to make a confession wall hand in hand. Express your love to the person you want

Mysql23 storage engine
随机推荐
Super detailed steps for pushing wechat official account H5 messages
MySQL底层的逻辑架构
MySQL23-存储引擎
Software test engineer development planning route
MySQL27-索引优化与查询优化
Mysql35 master slave replication
Global and Chinese markets of static transfer switches (STS) 2022-2028: Research Report on technology, participants, trends, market size and share
Mysql21 - gestion des utilisateurs et des droits
Complete web login process through filter
Mysql22 logical architecture
Mysql27 index optimization and query optimization
Transactions have four characteristics?
Database middleware_ MYCAT summary
Technology | diverse substrate formats
Adaptive Bezier curve network for real-time end-to-end text recognition
解决在window中远程连接Linux下的MySQL
MySQL learning diary (II)
A necessary soft skill for Software Test Engineers: structured thinking
The underlying logical architecture of MySQL
实现微信公众号H5消息推送的超级详细步骤