当前位置:网站首页>简述controller,service,repository注解的用法(谈谈application.properties的作用)
简述controller,service,repository注解的用法(谈谈application.properties的作用)
2022-07-30 10:31:00 【全栈程序员站长】
大家好,又见面了,我是你们的朋友全栈君。
Spring 2.5 中除了提供 @Component 注释外,还定义了几个拥有特殊语义的注释,它们分别是:@Repository、@Service 和 @Controller。 在目前的 Spring 版本中,这 3 个注释和 @Component 是等效的,但是从注释类的命名上,很容易看出这 3 个注释分别和持久层、业务层和控制层(Web 层)相对应。
1、@Component
@Component 是所有受Spring 管理组件的通用形式,@Component注解可以放在类的头上,@Component不推荐使用。
2、@Controller
@Controller对应表现层的Bean,也就是Action,例如:
@Controller
@Scope("prototype")
public class UserAction extends BaseAction<User>{
……
}使用@Controller注解标识UserAction之后,就表示要把UserAction交给Spring容器管理,在Spring容器中会存在一个名字为”userAction”的action,这个名字是根据UserAction类名来取的。注意:如果@Controller不指定其value【@Controller】,则默认的bean名字为这个类的类名首字母小写,如果指定<
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/129625.html原文链接:https://javaforall.cn
边栏推荐
- Drag and drop events, dataTransfer, getBoundingClientRect
- Selected System Design | Design of CAN Bus Controller Based on FPGA (with Code)
- kubernetes的一些命令
- Scrapy爬虫之网站图片爬取
- js对数组操作移动进行封装
- Unity 锁定相机第二弹
- MySQL之数据库维护
- Basemap and Seaborn
- If someone asks you about distributed transactions again, throw this to him
- jmeter接口压力测试-(二)
猜你喜欢

vscode中写markdown格式笔记的配置过程和相关语法

神经网络学习笔记4——自动编码器(含稀疏,堆叠)(更新中)

Nacos configuration in the project of battle

Security Thought Project Summary

spark udf 接受并处理 null值.

Understanding of deadlock

Classes and Objects - 6 Default Member Functions

在机器人行业的专业人士眼里,机器人行业目前的情况如何?

Flink_CDC construction and simple use

【HMS core】【FAQ】HMS Toolkit Typical Questions Collection 1
随机推荐
MFCC转音频,效果不要太逗>V<!
易基因:人类tRNA基因位点表现出与衰老相关的DNA高甲基化|研究文章
Meikle Studio - see the actual combat notes of Hongmeng equipment development five - drive subsystem development
Matplotlib--plot markers
[Qualcomm][Network] 网络拨号失败和netmgrd服务分析
自适应控制——仿真实验一 用李雅普诺夫稳定性理论设计自适应规律
OC-关于alloc和dealloc(还没开始写)
系统设计精选 | 基于FPGA的CAN总线控制器的设计(附代码)
OC-ARC (Automatic Reference Counting) automatic reference counting
多线程保证单个线程开启事务并生效的方案
Beyond Stream Processing !第四届实时计算 Flink 挑战赛启动,49 万奖金等你来拿!
XYplorer 23多语言,最好的管理软件之一
数据库事务,JDBC操作和数据类型
Multi-threading scheme to ensure that a single thread opens a transaction and takes effect
Alibaba Cloud OSS Object Storage
Basemap和Seaborn
(C语言)文件操作
关于verilog的时延研究
Selected System Design | Design of CAN Bus Controller Based on FPGA (with Code)
安全提示:Qt中的FreeType