当前位置:网站首页>基于注解的三层项目的改造及添加包扫描的方式
基于注解的三层项目的改造及添加包扫描的方式
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>
会降低容器启动的速度,导致多做无用功。

边栏推荐
- How does excel filter out the content you want? Excel table filtering content tutorial
- Use annotation test in idea
- Youxuan database failed to start and reported network error
- Operator operation list of spark
- Sparksql inserts or updates in batches and saves data to MySQL
- 使用Jstack、Jconsole和jvisualvm进行死锁分析
- Open the tutorial of adding and modifying automatically playing music on the open zone website
- Excel怎么筛选出自己想要的内容?excel表格筛选内容教程
- 带你搞懂 Kubernetes 集群中几种常见的流量暴露方案
- stack和queue和优先级队列(大堆和小堆)模拟实现和仿函数讲解
猜你喜欢

ODOO开发教程之图表

Create a mindscore environment in modelars, install mindvision, and conduct in-depth learning and training (Huawei)

输入的查询SQL语句,是如何执行的?

Mysql的自连接和联合查询

How does word view document modification traces? How word views document modification traces

电脑无法打开excel表格怎么办?excel打不开的解决方法

Office提示系统配置无法运行怎么办?

Apache POI实现Excel导入读取数据和写入数据并导出

Solution to the fourth game of 2022 Hangzhou Electric Multi school league

Use jupyter (2) to establish shortcuts to open jupyter and common shortcut keys of jupyter
随机推荐
搭建手机APP需要用到什么服务器
Youxuan database failed to start and reported network error
Wps如何使用智能填充快速填充数据?Wps快速填充数据的方法
自贸经济中架起的“隐形桥梁”:国货精品与中国AI力量
Traffic flow prediction pit climbing record (I): traffic flow data set, original data
stack和queue和优先级队列(大堆和小堆)模拟实现和仿函数讲解
The song of the virtual idol was originally generated in this way!
WPS插入超链接无法打开,提示“无法打开指定文件”怎么办!
JS daily question (11)
Torch.nn.crossentropyloss() details
Lenovo Savior r7000+ add ssd+ copy and partition the information of the original D disk to the new SSD
Wechat picture identification
tmux随笔
Quick start JDBC
网安学习-内网安全1
传奇开区网站如何添加流量统计代码
Exception - ...MaxUploadSizeExceededException: Maximum upload size exceeded; nested exception is ...
office2010每次打开都要配置进度怎么解决?
Pytorch learning notes
How to monitor micro web services