当前位置:网站首页>@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容器中进行管理
边栏推荐
- Security design verification of API interface: ticket, signature, timestamp
- MySQL Real Time Optimization Master 04 discute de ce qu'est binlog en mettant à jour le processus d'exécution des déclarations dans le moteur de stockage InnoDB.
- Isn't there anyone who doesn't know how to write mine sweeping games in C language
- Windchill配置远程Oracle数据库连接
- MySQL20-MySQL的数据目录
- 保姆级手把手教你用C语言写三子棋
- Software test engineer development planning route
- MySQL21-用户与权限管理
- [reading notes] rewards efficient and privacy preserving federated deep learning
- Solution to the problem of cross domain inaccessibility of Chrome browser
猜你喜欢
[reading notes] rewards efficient and privacy preserving federated deep learning
MySQL 20 MySQL data directory
【C语言】深度剖析数据存储的底层原理
Implement context manager through with
MySQL底层的逻辑架构
MySQL24-索引的数据结构
Not registered via @enableconfigurationproperties, marked (@configurationproperties use)
Security design verification of API interface: ticket, signature, timestamp
MySQL23-存儲引擎
API learning of OpenGL (2003) gl_ TEXTURE_ WRAP_ S GL_ TEXTURE_ WRAP_ T
随机推荐
16 medical registration system_ [order by appointment]
API learning of OpenGL (2003) gl_ TEXTURE_ WRAP_ S GL_ TEXTURE_ WRAP_ T
评估方法的优缺点
Time in TCP state_ The role of wait?
MySQL combat optimization expert 02 in order to execute SQL statements, do you know what kind of architectural design MySQL uses?
UnicodeDecodeError: ‘utf-8‘ codec can‘t decode byte 0xd0 in position 0成功解决
MySQL35-主从复制
Global and Chinese market of wafer processing robots 2022-2028: Research Report on technology, participants, trends, market size and share
Isn't there anyone who doesn't know how to write mine sweeping games in C language
Not registered via @enableconfigurationproperties, marked (@configurationproperties use)
How to find the number of daffodils with simple and rough methods in C language
How to change php INI file supports PDO abstraction layer
MySQL 20 MySQL data directory
Pytoch LSTM implementation process (visual version)
Mysql32 lock
Not registered via @EnableConfigurationProperties, marked(@ConfigurationProperties的使用)
PyTorch RNN 实战案例_MNIST手写字体识别
Just remember Balabala
Technology | diverse substrate formats
使用OVF Tool工具从Esxi 6.7中导出虚拟机