当前位置:网站首页>简述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
边栏推荐
- Re16: Read the paper ILDC for CJPE: Indian Legal Documents Corpus for Court Judgment Prediction and Explanation
- AB测试 总结归纳
- 安全提示:Qt中的FreeType
- In 2022, the top will be accepted cca shut the list
- 拖放事件,dataTransfer,getBoundingClientRect
- 数据库事务,JDBC操作和数据类型
- 在机器人行业的专业人士眼里,机器人行业目前的情况如何?
- 【HarmonyOS】【ARK UI】HarmonyOS ets语言怎么实现双击返回键退出
- [100个Solidity使用技巧]1、合约重入攻击
- Database dirty reads, non-repeatable reads, phantom reads and corresponding isolation levels
猜你喜欢

系统设计精选 | 基于FPGA的CAN总线控制器的设计(附代码)

Beyond Stream Processing !第四届实时计算 Flink 挑战赛启动,49 万奖金等你来拿!

Multithreading--the usage of threads and thread pools

Meikle Studio - see the actual combat notes of Hongmeng device development 4 - kernel development

易基因:人类tRNA基因位点表现出与衰老相关的DNA高甲基化|研究文章

async.js入门

360发布面向未来的EDR,全方位守护政企用户终端安全

Pytorch中 nn.Transformer的使用详解与Transformer的黑盒讲解

In the robot industry professionals, Mr Robot industry current situation?

Practical Walkthrough | Calculate Daily Average Date or Time Interval in MySQL
随机推荐
OC-ARC(Automatic Reference Counting)自动引用计数
[AGC] Growth Service 2 - In-App Message Example
Practical Walkthrough | Calculate Daily Average Date or Time Interval in MySQL
360发布面向未来的EDR,全方位守护政企用户终端安全
360 released a future-oriented EDR to protect the security of government and enterprise user terminals in an all-round way
Re20:读论文的先例:普通法的信息理论分析
async.js入门
Shell system learning function
【C和指针第七章】可变参数列表
wsl操作
Re19: Read the paper Paragraph-level Rationale Extraction through Regularization: A case study on European Court
Flink_CDC construction and simple use
Adaptive Control - Simulation Experiment 1 Designing Adaptive Laws Using Lyapunov's Stability Theory
SST-Calib: A lidar-visual extrinsic parameter calibration method combining semantics and VO for spatiotemporal synchronization calibration (ITSC 2022)
多线程--线程和线程池的用法
mysql与redis 区别
STM32CubeMX configuration to generate FreeRTOS project
现在报PMP还来得及参加9月的考试吗?分享敏捷全真模拟题
In 2022, the top will be accepted cca shut the list
正则表达式快速入门笔记