当前位置:网站首页>三层项目的架构分析及构造方法的参数名称注入
三层项目的架构分析及构造方法的参数名称注入
2022-07-29 05:07:00 【是庸医啊】
目录
三层项目的架构分析
使用三层架构进行用户的插入操作
界面层,业务逻辑层,数据访问层(模拟)
Spring会接管三层架构中哪些对象的创建?界面层的对象,业务逻辑层的对象,数据访问层的对象。
非Spring接管下的三层项目构建:
实体类
com.bjpowernode.pojo Users
数据访问层
com.bjpowernode.dao UsersMapper.java(接口)
UsersMapperImpl.java(实现类)
业务逻辑层
com.bjpowernode.service UsersService.java(接口)
UsersServiceImpl.java(实现类 )
界面层
com.bjpowernode.controller UsersController.java
接下里我们继续搭建一个框架
然后创建一个新的实体类
实体类里面的set、get方法都要加!(Alt+Insert)
spring接管三层对象的创建
数据访问层的逻辑对象
业务逻辑层
界面层
最后一步就是测试
测试的三个步骤要搞得明明白白!一定!
使用构造方法参数名称注入值
使用构造方法的参数名称进行注入值
Student stu = new Student("张三",22);
a.使用构造方法的参数名称进行注入值
<bean id="school" class="com.bjpowernode.pojo3.School">
<constructor-arg name="name1" value="清华大学"></constructor-arg>
<constructor-arg name="address1" value="海淀区"></constructor-arg>
</bean>
c.使用默认的构造方法的参数的顺序注入值
<bean id="stuSequence" class="com.bjpowernode.pojo3.Student">
<constructor-arg value="陈十"></constructor-arg>
<constructor-arg value="22"></constructor-arg>
<constructor-arg ref="school"></constructor-arg>
</bean>
然后我们测试一下
构造方法的名称作为注入值
使用构造方法参数的下标进行注入值
b.使用构造方法参数的下标注入值
<bean id="stu" class="com.bjpowernode.pojo3.Student">
<constructor-arg index="0" value="钱七"></constructor-arg>
<constructor-arg index="1" value="22"></constructor-arg>
<constructor-arg index="2" ref="school"></constructor-arg>
</bean>
使用构造方法默认的参数进行赋值
边栏推荐
- Solve the warning prompt of MySQL mapping file
- Learn the first program of database
- "Invisible Bridge" built in the free trade economy: domestic products and Chinese AI power
- 2021-11-02
- P5714 [deep foundation 3. Case 7] obesity
- TMUX essays
- DataSourceClosedException: dataSource already closed at Mon Oct 25 16:55:48 CST 2021
- MySQL定时调用预置函数完成数据更新
- Unity metaverse (III), protobuf & socket realize multi person online
- How to monitor micro web services
猜你喜欢
js(forEach)出现return无法结束函数的解决方法
Academic | [latex] super detailed texlive2022+tex studio download installation configuration
Excel怎么筛选出自己想要的内容?excel表格筛选内容教程
The representation of time series analysis: is the era of learning coming?
1 sentence of code, get asp Net core binds multiple sources to the same class
Northeast University Data Science Foundation (matlab) - Notes
The most comprehensive promotion plan for the launch of new products
Flink+iceberg environment construction and production problem handling
Apache POI实现Excel导入读取数据和写入数据并导出
How to add a map to the legendary server
随机推荐
JS daily question (10)
Northeast University Data Science Foundation (matlab) - Notes
Glory 2023 push, push code ambubk
Conv2d of torch
Simple user-defined authentication interface rules
[wechat applet] swiper slides the page, and the left and right sides of the slider show part of the front and back, showing part of the front and back
Create a mindscore environment in modelars, install mindvision, and conduct in-depth learning and training (Huawei)
How does WPS use smart fill to quickly fill data? WPS method of quickly filling data
传奇开区网站如何添加流量统计代码
1 sentence of code, get asp Net core binds multiple sources to the same class
Mysql把查询到的结果集按指定顺寻进行排序
Exception - ...MaxUploadSizeExceededException: Maximum upload size exceeded; nested exception is ...
Pivot table of odoo development tutorial
网安学习-内网安全1
Climbing the pit of traffic flow prediction (II): the simplest LSTM predicts traffic flow using tensorflow2
【微信小程序】swiper滑动页面,滑块左右各露出前后的一部分,露出一部分
如何让照片中的人物笑起来?HMS Core视频编辑服务一键微笑功能,让人物笑容更自然
Network Security Learning - Intranet Security 1
ODOO开发教程之图表
向往的开源之多YOUNG新生 | 从开源到就业的避坑指南来啦!