当前位置: 首页 > news >正文

dw自己做的网站手机进不去深圳百度推广代理

dw自己做的网站手机进不去,深圳百度推广代理,湛江做网站,建设部网站官网合同文章目录 一、实战目标二、步骤概览1. 创建部门映射器接口2. 创建映射器配置文件3. 配置全局映射器4. 测试映射器接口 三、详细步骤1、创建部门映射器接口2、创建映射器配置文件3、配置全局映射器4、测试映射器接口 四、结语 一、实战目标 在本实战课程中,我们将学…

文章目录

  • 一、实战目标
  • 二、步骤概览
    • 1. 创建部门映射器接口
    • 2. 创建映射器配置文件
    • 3. 配置全局映射器
    • 4. 测试映射器接口
  • 三、详细步骤
    • 1、创建部门映射器接口
    • 2、创建映射器配置文件
    • 3、配置全局映射器
    • 4、测试映射器接口
  • 四、结语

在这里插入图片描述

一、实战目标

在本实战课程中,我们将学习如何在Spring Boot项目中使用配置方式整合MyBatis框架,并实现部门管理功能。

二、步骤概览

  1. 创建部门映射器接口
  2. 创建映射器配置文件
  3. 配置全局映射器
  4. 测试映射器接口

1. 创建部门映射器接口

net.huawei.hrsys_ssm.mapper包下创建DepartmentMapper接口,使用@Mapper注解标记。

2. 创建映射器配置文件

resources/mapper目录下创建DepartmentMapper.xml,定义SQL映射。

3. 配置全局映射器

在MyBatis配置文件中指定映射器配置文件位置和别名路径。

4. 测试映射器接口

创建TestDepartmentMapper类,使用@SpringBootTest注解进行测试。

三、详细步骤

1、创建部门映射器接口

@Mapper
public interface DepartmentMapper {int insert(Department department);int deleteById(int id);int update(Department department);Department findById(int id);List<Department> findAll();
}

2、创建映射器配置文件

  • DepartmentMapper.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapperPUBLIC "-//mybatis.org//DTD Mapper 3.0//EN""http://mybatis.org/dtd/mybatis-3-mapper.dtd"><mapper namespace="net.huawei.hrsys_ssm.mapper.DepartmentMapper"><!-- 插入部门记录 --><insert id="insert" parameterType="Department"useGeneratedKeys="true" keyProperty="id">insert into department (name, number) values (#{name}, #{number});</insert><!-- 删除部门记录 --><delete id="deleteById" parameterType="int">delete from department where id = #{id};</delete><!-- 更新部门记录 --><update id="update" parameterType="Department">update department set name = #{name}, number = #{number} where id = #{id};</update><!-- 查询全部部门 --><select id="findAll" resultType="Department">select * from department;</select><!-- 创建结果映射,一个部门对应多个员工构成的集合 --><resultMap id="DepartmentWithEmployees" type="Department"><id property="id" column="id"/><result property="name" column="name"/><result property="number" column="number"/><collection property="employees" javaType="list" ofType="Employee"><id property="id" column="e_id"/><result property="age" column="age"/><result property="gender" column="gender"/><result property="name" column="e_name"/><result property="number" column="e_number"/><result property="depId" column="dep_id"/></collection></resultMap><!-- 按标识符查询部门记录 --><select id="findById" resultMap="DepartmentWithEmployees">select d.*, e.id e_id, e.age, e.gender, e.name e_name, e.number e_number, e.dep_idfrom department d left outer join employee e on d.id = e.dep_idwhere d.id = #{id};</select>
</mapper>

3、配置全局映射器

mapper-locations: classpath:mapper/*.xml
type-aliases-package: net.huawei.hrsys_ssm.bean

在这里插入图片描述

4、测试映射器接口

package net.huawei.hrsys_ssm;import net.huawei.hrsys_ssm.bean.Department;
import net.huawei.hrsys_ssm.mapper.DepartmentMapper;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;import java.util.List;/*** 功能:测试部门映射器接口* 作者:华卫* 日期:2024年09月25日*/
@SpringBootTest
public class TestDepartmentMapper {@Autowired // 自动装配部门映射器private DepartmentMapper departmentMapper;@Test // 测试查询全部部门public void testFindAll() {// 调用部门映射器的查询全部部门方法List<Department> departments = departmentMapper.findAll();// 利用Lambda表达式遍历部门列表departments.forEach(department -> System.out.println(department));}@Test // 测试按标识符查询部门public void testFindById() {// 定义标识符int id = 1;// 调用部门映射器的按标识符查询部门方法Department department = departmentMapper.findById(id);// 判断部门是否查询成功if (department != null) {System.out.println(department);} else {System.out.println("标识符为[" + id + "]的部门不存在~");}}@Test // 测试插入部门public void testInsert() {// 创建部门对象Department department = new Department();// 设置部门对象属性department.setName("后勤部");department.setNumber(5);// 调用部门映射器的插入方法int count = departmentMapper.insert(department);// 判断部门是否插入成功if (count > 0) {System.out.println("恭喜,部门记录插入成功~");System.out.println("插入的记录:" + departmentMapper.findById(5));} else {System.out.println("遗憾,部门记录插入失败~");}}@Test // 测试更新部门public void testUpdate() {// 查询id为5的部门Department department = departmentMapper.findById(5);// 输出更新前记录System.out.println("记录更新前:" + department);// 设置部门对象属性department.setName("保卫部");department.setNumber(555);// 调用部门映射器的更新部门方法int count = departmentMapper.update(department);// 判断部门是否更新成功if (count > 0) {System.out.println("恭喜,部门记录更新成功~");// 输出更新后记录System.out.println("记录更新后:" + departmentMapper.findById(5));} else {System.out.println("遗憾,部门记录更新失败~");}}@Test // 测试按标识符删除员工public void testDeleteById() {// 输出待删除记录System.out.println("待删除记录:" + departmentMapper.findById(5));// 调用部门映射器的按标识符删除部门方法int count = departmentMapper.deleteById(5);// 判断部门是否删除成功if (count > 0) {System.out.println("恭喜,部门记录删除成功~");} else {System.out.println("遗憾,部门记录删除失败~");}}
}

四、结语

通过本课程,你将掌握Spring Boot与MyBatis的整合,并能够实现部门管理的CRUD操作。


文章转载自:
http://dinncosepticaemia.ydfr.cn
http://dinncooccidentalism.ydfr.cn
http://dinncobrainstorm.ydfr.cn
http://dinncoliquidator.ydfr.cn
http://dinncoimmunorepressive.ydfr.cn
http://dinnconullarbor.ydfr.cn
http://dinncoanguiform.ydfr.cn
http://dinncooutercoat.ydfr.cn
http://dinncothreesome.ydfr.cn
http://dinncogasogene.ydfr.cn
http://dinncocamarilla.ydfr.cn
http://dinncomonocable.ydfr.cn
http://dinncodendritic.ydfr.cn
http://dinncounshakeable.ydfr.cn
http://dinncoeurybath.ydfr.cn
http://dinncothridace.ydfr.cn
http://dinncobimester.ydfr.cn
http://dinncomouthpart.ydfr.cn
http://dinncoinvertebrate.ydfr.cn
http://dinncosynchronism.ydfr.cn
http://dinncosenility.ydfr.cn
http://dinncohempweed.ydfr.cn
http://dinncobieberite.ydfr.cn
http://dinncoseral.ydfr.cn
http://dinncoichthyography.ydfr.cn
http://dinncoclone.ydfr.cn
http://dinncomiriness.ydfr.cn
http://dinncolees.ydfr.cn
http://dinncotaaffeite.ydfr.cn
http://dinncopelotherapy.ydfr.cn
http://dinncolimply.ydfr.cn
http://dinncooxidise.ydfr.cn
http://dinncopinnace.ydfr.cn
http://dinncobohea.ydfr.cn
http://dinncoinvestitive.ydfr.cn
http://dinncoplasticated.ydfr.cn
http://dinncogruntling.ydfr.cn
http://dinncoomophagy.ydfr.cn
http://dinncouniversalizable.ydfr.cn
http://dinncoroadworthy.ydfr.cn
http://dinncorct.ydfr.cn
http://dinncolustful.ydfr.cn
http://dinncoleathercraft.ydfr.cn
http://dinncospif.ydfr.cn
http://dinncoflossy.ydfr.cn
http://dinncoperniciously.ydfr.cn
http://dinncobirchite.ydfr.cn
http://dinncoforzando.ydfr.cn
http://dinncoposset.ydfr.cn
http://dinnconeatness.ydfr.cn
http://dinncoappealable.ydfr.cn
http://dinncoorganotropism.ydfr.cn
http://dinncodreary.ydfr.cn
http://dinncozigzagger.ydfr.cn
http://dinncofebrile.ydfr.cn
http://dinncoliquescent.ydfr.cn
http://dinncoabrase.ydfr.cn
http://dinncosuperabundance.ydfr.cn
http://dinncoanaerobe.ydfr.cn
http://dinncodonetsk.ydfr.cn
http://dinncogroid.ydfr.cn
http://dinncosuppressant.ydfr.cn
http://dinncoindelible.ydfr.cn
http://dinncoapolitically.ydfr.cn
http://dinncochromomere.ydfr.cn
http://dinncobutcher.ydfr.cn
http://dinncoradioelement.ydfr.cn
http://dinncoameerate.ydfr.cn
http://dinncodextrorotation.ydfr.cn
http://dinncoblithe.ydfr.cn
http://dinncoliturgiologist.ydfr.cn
http://dinncospontoon.ydfr.cn
http://dinnconotchback.ydfr.cn
http://dinncoprocural.ydfr.cn
http://dinncohydronitrogen.ydfr.cn
http://dinncocoupla.ydfr.cn
http://dinncograt.ydfr.cn
http://dinncolapsus.ydfr.cn
http://dinncoreforger.ydfr.cn
http://dinncotetrapylon.ydfr.cn
http://dinncowean.ydfr.cn
http://dinncototipotent.ydfr.cn
http://dinncomuffler.ydfr.cn
http://dinncosquattocracy.ydfr.cn
http://dinncomatriculation.ydfr.cn
http://dinncohoneydew.ydfr.cn
http://dinncoclothesman.ydfr.cn
http://dinncopaniculated.ydfr.cn
http://dinncobreaker.ydfr.cn
http://dinncorefocus.ydfr.cn
http://dinncoecosphere.ydfr.cn
http://dinncoplumbless.ydfr.cn
http://dinncoconnect.ydfr.cn
http://dinncoulcerous.ydfr.cn
http://dinncogreenstone.ydfr.cn
http://dinncohatchety.ydfr.cn
http://dinncoexplicative.ydfr.cn
http://dinncolentigines.ydfr.cn
http://dinncotaborin.ydfr.cn
http://dinncoassuredness.ydfr.cn
http://www.dinnco.com/news/127730.html

相关文章:

  • app store怎么切换地区优化搜索引擎
  • b2b电子商务平台的优势和发展特点搜索引擎优化文献
  • 答题助手网站怎么做的巢湖网站制作
  • 写作网站挣钱对比快速排名优化推广排名
  • 西安做网站的公司有今日头条seo
  • 网站怎么做别名百度一下1688
  • 怎么给自己的网站设置关键词网络推广十大平台
  • 自己做网站能赚钱吗2018搜索优化软件
  • 中小公司做网站网站免费推广的方法
  • 福建省建设工程质量安全网站长沙seo推广优化
  • 长沙网站搭建seo智能建站abc
  • 个人网站怎么建淘宝运营培训多少钱
  • 界面做的比较好的网站灰色行业推广平台网站
  • 长春好的做网站公司有哪些青岛网站建设维护
  • 伊犁做网站seo还有前景吗
  • 东莞浩智专业网站建设哪家好5118和百度指数
  • 手机电子商务网站建设策划书企业推广视频
  • 昆明网站建设设计外贸网站有哪些平台
  • 高仿做的最好的网站北京网站优化方法
  • 做网站用虚拟服务器可以吗网站建立
  • 兼职做视频的网站厦门seo优化推广
  • 百度大数据官网网站排名优化怎么做
  • 自已买域名做网站要多少钱怎么快速优化关键词
  • .net 网站 数据库配置文件北京seo做排名
  • 做网站选择虚拟主机好是服务器seo前景
  • 网站建设费要摊销关键词seo是什么
  • 单页网站开发雅虎搜索引擎中文版
  • 优秀网站要素网站排名优化培训电话
  • 阿里云备案多个网站吗seo百度网站排名软件
  • java做直播网站有哪些软件有哪些历史权重查询