当前位置:网站首页>基于注解的三层项目的改造及添加包扫描的方式
基于注解的三层项目的改造及添加包扫描的方式
2022-07-29 05:07:00 【是庸医啊】
目录
基于注解的三层项目的改造
只要是基于注解的开发,必须包扫描
数据访问层的实体类
@Repository:专门用来创建数据访问层的对象,负责数据库中的增删改查所有操作
业务逻辑层的实现类
@Autowired:使用类型注入值,从整个Bean工厂中搜索同源类型的对象进行注入
界面层
测试
添加包扫描的方式
1)单个包扫描(推荐使用)
<context:component-scan base-package="com.bjpowernode.controller"></context:component-scan>
<context:component-scan base-package="com.bjpowernode.service.impl"></context:component-scan>
<context:component-scan base-package="com.bjpowernode.dao"></context:component-scan>
2)多个包扫描,多个包之间以逗号或空格或分号分隔
<context:component-scan base-package="com.bjpowernode.controller com.bjpowernode.service ,com.bjpowernode.dao"></context:component-scan>
3)扫描根包(不推荐)
<context:component-scan base-package="com.bjpowernode"></context:component-scan>
会降低容器启动的速度,导致多做无用功。
边栏推荐
- Conv2d of torch
- 2021-11-02
- Wps如何使用智能填充快速填充数据?Wps快速填充数据的方法
- Office提示系统配置无法运行怎么办?
- 【config】配置数组参数
- How to install Office2010 installation package? How to install Office2010 installation package on computer
- Live in small private enterprises
- Flink+Iceberg环境搭建及生产问题处理
- JDBC statement + resultset introduction
- Word如何查看文档修改痕迹?Word查看文档修改痕迹的方法
猜你喜欢
SM整合原来这么简单,步骤清晰(详细)
2021-10-23
How to monitor micro web services
Diagram of odoo development tutorial
Network Security Learning - Intranet Security 1
Huawei ilearning AI mathematics foundation course notes
What if excel is stuck and not saved? The solution of Excel not saved but stuck
On prepayment of house purchase
电脑无法打开excel表格怎么办?excel打不开的解决方法
Glory 2023 push, push code ambubk
随机推荐
带你搞懂 Kubernetes 集群中几种常见的流量暴露方案
JS daily question (11)
On prepayment of house purchase
Solution | get the relevant information about the current employees' highest salary in each department |
搭建手机APP需要用到什么服务器
Learn the first program of database
【config】配置数组参数
Excel卡住了没保存怎么办?Excel还没保存但是卡住了的解决方法
Youxuan database failed to start and reported network error
JDBC statement + resultset introduction
让你的正则表达式可读性提高一百倍
Climbing the pit of traffic flow prediction (II): the simplest LSTM predicts traffic flow using tensorflow2
2021-11-02
Google GTEST event mechanism
The most comprehensive promotion plan for the launch of new products
pytorch学习笔记
Learn matlab to draw geographical map, line scatter bubble density map
Use jupyter (2) to establish shortcuts to open jupyter and common shortcut keys of jupyter
虚拟偶像的歌声原来是这样生成的!
MySQL time calculation function