Mybatis:自定义映射resultMap(7)

news2024/10/7 8:29:04

Mybaits笔记框架:https://blog.csdn.net/qq_43751200/article/details/128154837

自定义映射resultMap

  • 1. Mybatis环境搭建
  • 2. 问题引入
  • 3. 解决表中的字段名和对应类的属性名不一致问题
    • 方式一: 为字段起别名,保持和属性名的一致
    • 方式二:设置全局配置,将下划线_自动映射为驼峰
    • 方式三:通过resultMap设置自定义的映射关系
  • 4. 多对一映射处理
    • 方式一:级联方式处理映射关系
    • 方式二:使用association处理映射关系
    • 方式三:分步查询
  • 5. 一对多映射处理
    • 方式一:使用collection处理映射关系
    • 方式二:分布查询
  • 6.延迟加载

1. Mybatis环境搭建

创建数据库表

-- 创建t_emp表
create table t_emp(
	eid int NOT NULL PRIMARY KEY, 
	emp_name varchar(20),
	age int,
	sex char,
	email varchar(20),
	did int
)

-- 向t_emp表中插入数据
insert into t_emp(eid, emp_name, age, sex, email, did)
values(1, 'lsm', 23, '男', '1234@qq.com', 1),
			(2, 'yxy', 23, '男', '1234@qq.com', 2),
			(3, 'lxy1', 23, '男', '1234@qq.com', 3),
			(4, 'yxy_lsm', 23, '男', '1234@qq.com', 2),
			(5, 'lxy', 23, '男', '1234@qq.com', 1)


-- 创建t_dept表
create table t_dept(
	did int,
	dept_name varchar(20)
)

-- 向t_dept表中插入数据
insert into t_dept(did, dept_name) values(1, 'A'),(2, 'B'),(3, 'C')

在这里插入图片描述

在这里插入图片描述

在maven项目中创建对应的实体类(Empt类 和 Dept类)
Emp类

package com.atguigu.pojo;

/**
 * @Author Mr.Lu
 * @Date 2022/12/2 19:08
 * @ClassName Emp
 * @Version 1.0
 */
public class Emp {
    private Integer eid;
    // t_emp表该列名为emp_name
    private String empName;
    private  Integer age;
    private String sex;
    private String email;

    public Emp() {
    }

    public Emp(Integer eid, String empName, Integer age, String sex, String email) {
        this.eid = eid;
        this.empName = empName;
        this.age = age;
        this.sex = sex;
        this.email = email;
    }

    public Integer getEid() {
        return eid;
    }

    public void setEid(Integer eid) {
        this.eid = eid;
    }

    public String getEmpName() {
        return empName;
    }

    public void setEmpName(String empName) {
        this.empName = empName;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    @Override
    public String toString() {
        return "Emp{" +
                "eid=" + eid +
                ", empName='" + empName + '\'' +
                ", age=" + age +
                ", sex='" + sex + '\'' +
                ", email='" + email + '\'' +
                '}';
    }
}

Dept类

package com.atguigu.pojo;

/**
 * @Author Mr.Lu
 * @Date 2022/12/2 19:07
 * @ClassName Dept
 * @Version 1.0
 */
public class Dept {
    private Integer did;
    // t_dept表该列名为dept_name
    private String deptName;

    public Dept() {
    }

    public Dept(Integer did, String deptName) {
        this.did = did;
        this.deptName = deptName;
    }

    public Integer getDid() {
        return did;
    }

    public void setDid(Integer did) {
        this.did = did;
    }

    public String getDeptName() {
        return deptName;
    }

    public void setDeptName(String deptName) {
        this.deptName = deptName;
    }

    @Override
    public String toString() {
        return "Dept{" +
                "did=" + did +
                ", deptName='" + deptName + '\'' +
                '}';
    }
}

项目结构

在这里插入图片描述

2. 问题引入

DeptMapper接口

   /**
     * 获取表t_Emp的所有信息
     * @return
     */
    List<Emp> getEmpAll();

DeptMapper接口对应的DeptMapper.xml配置文件

    <!--List<Emp> getEmpAll();-->
    <select id="getEmpAll" resultType="Emp">
        select * from t_emp
    </select>

测试方法

 @Test
    public void testGetEmpAll(){
        SqlSession sqlSession = SqlSessionFactoryUtils.getSqlSession();
        EmpMapper empMapper = sqlSession.getMapper(EmpMapper.class);
        List<Emp> empAll = empMapper.getEmpAll();
        for(Emp emp : empAll){
            System.out.println(emp);
        }
        sqlSession.close();
    }

在这里插入图片描述

问题描述:经过上图发现empName对应的值都为null,但是t_emp表中的emp_name是存在值的,这是为什么呐?。经过分析产生这种情况的原因在于表中的字段名和对应类的属性名不一致,这个要如何解决呐?

3. 解决表中的字段名和对应类的属性名不一致问题

方式一: 为字段起别名,保持和属性名的一致

在EmpMapper.xml中为字段起别名

    <!--解决实体类中的属性名称和对应表中的列名不一致问题,方式1: 起别名-->
    <select id="getEmpAll" resultType="Emp">
        select eid, emp_name empName, age, sex, email from t_emp
    </select>

测试方法测试:

在这里插入图片描述

方式二:设置全局配置,将下划线_自动映射为驼峰

可以在MyBatis的核心配置文件中的setting标签中,设置一个全局配置信息mapUnderscoreToCamelCase,可以在查询表中数据时,自动将_类型的字段名转换为驼峰,例如:字段名user_name,设置了mapUnderscoreToCamelCase,此时字段名就会转换为userName。

在mybatis-config.xml核心配置文件中加入对应的setting标签

    <!--设置Mybatis的全局配置-->
    <settings>
        <!--将下划线_自动映射为驼峰,emp_name : empName -->
        <setting name="mapUnderscoreToCamelCase" value="true"/>
    </settings>

测试方法测试:

在这里插入图片描述

方式三:通过resultMap设置自定义的映射关系

  • resultMap:设置自定义映射

  • 属性:

    • id:表示自定义映射的唯一标识,不能重复

    • type:查询的数据要映射的实体类的类型, 例如User、Emp等实体类型

    • 子标签:

      • id:设置主键的映射关系

      • result:设置普通字段的映射关系

      • 子标签属性:

      • property:设置映射关系中实体类中的属性名

      • column:设置映射关系中表中的字段名

  • 若字段名和实体类中的属性名不一致,则可以通过resultMap设置自定义映射,即使字段名和属性名一致的属性也要映射,也就是全部属性都要列出来

    <!--解决实体类中的属性名称和对应表中的列名不一致问题,方式3: resultMap方式-->
    <resultMap id="empResultMap" type="Emp">
        <id property="eid" column="eid"/>
        <result property="empName" column="emp_name"/>
        <result property="age" column="age"/>
        <result property="sex" column="sex"/>
        <result property="email" column="email"/>
    </resultMap>

    <select id="getEmpAll" resultMap="empResultMap">
        select * from t_emp
    </select>

测试方法测试:

在这里插入图片描述

4. 多对一映射处理

多个员工对应一个部门:多对一

一个部门对应多个员工:一对多

需求:查询员工信息以及员工所对应的部门信息

public class Emp {  
	private Integer eid;  
	private String empName;  
	private Integer age;  
	private String sex;  
	private String email;  
	private Dept dept;  // 该员工所属的部门
	//...构造器、get、set方法等
}

方式一:级联方式处理映射关系

EmpMapper接口

  /**
     * 根据t_emp表的eid查询emp和dept表,最后封装成Emp对象返回
     * @param eid
     * @return
     */
    Emp getEmpAndDeptById(Integer eid);

EmpMapper接口对应的EmpMapper.xml配置文件

    <!-- 处理多对一映射关系方式1: 使用级联属性赋值 -->
    <resultMap id="empAndDeptResultMap" type="Emp">
        <id property="eid" column="eid"/>
        <result property="empName" column="emp_name"/>
        <result property="empName" column="emp_name"/>
        <result property="age" column="age"/>
        <result property="sex" column="sex"/>
        <result property="email" column="email"/>
        <!--下面两行的column对应部门表t_dept的字段名称-->
        <result property="dept.did" column="did"/>
        <result property="dept.deptName" column="dept_name"/>
    </resultMap>

    <!--Emp getEmpAndDeptById(Integer eid);-->
    <select id="getEmpAndDeptById" resultMap="empAndDeptResultMap">
        select * from t_emp left join t_dept on t_emp.did = t_dept.did where t_emp.eid = #{eid}
    </select>

测试方法

 @Test
    public void testGetEmpAndDeptById(){
        SqlSession sqlSession = SqlSessionFactoryUtils.getSqlSession();
        EmpMapper empMapper = sqlSession.getMapper(EmpMapper.class);
        Emp emp = empMapper.getEmpAndDeptById(1);
        System.out.println(emp);
        sqlSession.close();
    }

在这里插入图片描述

方式二:使用association处理映射关系

EmpMapper接口

  /**
     * 根据t_emp表的eid查询emp和dept表,最后封装成Emp对象返回
     * @param eid
     * @return
     */
    Emp getEmpAndDeptById(Integer eid);

EmpMapper接口对应的EmpMapper.xml配置文件

     <!-- 处理多对一映射关系方式2: 使用association处理映射关系-->
    <resultMap id="empAndDeptResultMap" type="Emp">
        <id property="eid" column="eid"/>
        <result property="empName" column="emp_name"/>
        <result property="empName" column="emp_name"/>
        <result property="age" column="age"/>
        <result property="sex" column="sex"/>
        <result property="email" column="email"/>
        <!--
            association: 处理多对一的映射关系
            property: 需要处理多一的映射关系的属性名
            javaType: 该属性的类型
        -->
        <association property="dept" javaType="Dept">
            <id property="did" column="did"/>
            <result property="deptName" column="dept_name"/>
        </association>
    </resultMap>

    <!--Emp getEmpAndDeptById(Integer eid);-->
    <select id="getEmpAndDeptById" resultMap="empAndDeptResultMap">
        select * from t_emp left join t_dept on t_emp.did = t_dept.did where t_emp.eid = #{eid}
    </select>

测试方法

 @Test
    public void testGetEmpAndDeptById(){
        SqlSession sqlSession = SqlSessionFactoryUtils.getSqlSession();
        EmpMapper empMapper = sqlSession.getMapper(EmpMapper.class);
        Emp emp = empMapper.getEmpAndDeptById(3);
        System.out.println(emp);
        sqlSession.close();
    }

在这里插入图片描述

方式三:分步查询

查询员工信息

EmpMapper接口

 /**
     * 分布查询,员工及所对应的部门信息
     * 查询员工信息
     * @param eid
     * @return
     */
    Emp getEmpAndDeptByStepOne(@Param("eid") Integer eid);

EmpMapper接口对应的EmpMapper.xml配置文件

  • select:设置分布查询的sql的唯一标识(namespace.SQLId或mapper接口的全类名.方法名)
  • column:设置分步查询的条件
 <resultMap id="getEmpAndDeptByStepOneResultMap" type="Emp">
        <id property="eid" column="eid"/>
        <result property="empName" column="emp_name"/>
        <result property="age" column="age"/>
        <result property="sex" column="sex"/>
        <result property="email" column="email"/>
        <!--
            select:设置分布查询的sql的唯一标识(namespace.SQLId或mapper接口的全类名.方法名)
            column:设置分步查询的条件
        -->
        <association property="dept"
                     select="com.atguigu.mapper.DeptMapper.getEmpAndDeptByStepTwo"
                     column="did"/>
    </resultMap>

    <!-- Emp getEmpAndDeptByStepOne(@Param("eid") Integer eid);-->
    <select id="getEmpAndDeptByStepOne" resultMap="getEmpAndDeptByStepOneResultMap">
        select * from t_emp where eid = #{eid}
    </select>

查询部门信息

DeptMapper接口

 /**
     * 根据did查询部门信息
     * @param did
     * @return
     */
    Dept getEmpAndDeptByStepTwo(@Param("did") Integer did);

DeptMapper接口对应的DeptMapper.xml配置文件


    <resultMap id="getEmpAndDeptByStepTwoResultMap" type="Dept">
        <id property="did" column="did"/>
        <result property="deptName" column="dept_name"/>
    </resultMap>

    <!-- Dept getEmpAndDeptByStepTwo(@Param("did") Integer did);-->
    <select id="getEmpAndDeptByStepTwo" resultMap="getEmpAndDeptByStepTwoResultMap">
        select * from t_dept where did = #{did}
    </select>

测试方法

    @Test
    public void testGetEmpAndDeptByStepTwoAndOne(){
        SqlSession sqlSession = SqlSessionFactoryUtils.getSqlSession();
        EmpMapper empMapper = sqlSession.getMapper(EmpMapper.class);
        Emp emp = empMapper.getEmpAndDeptByStepOne(4);
        System.out.println(emp);
        sqlSession.close();
    }

在这里插入图片描述

5. 一对多映射处理

多个员工对应一个部门:多对一

一个部门对应多个员工:一对多

Dept类

public class Dept {
    private Integer did;
    private String deptName;
    private List<Emp> empList;  // 多对一:使用集合的形式
	//...构造器、get、set方法等
	// 注意要重写toString方式
}

方式一:使用collection处理映射关系

DeptMapper接口

    /**
     * 根据did查询部门信息以及其所包含的员工信息
     * @param did
     * @return
     */
    Dept getDeptAndEmp(@Param("did") Integer did);

DeptMapper接口对应的DeptMapper.xml配置文件

  <!--Dept getDeptAndEmp(@Param("did") Integer did);-->
    <!--方式一:使用功能collection方式处理多对一方式-->
    <resultMap id="getDeptAndEmpResultMap" type="Dept">
        <id property="did" column="did"/>
        <result property="deptName" column="dept_name"/>
        <!--
            collection:处理一对多的映射关系
            ofType:表示该属性所对应的集合中存储数据额类型
        -->
        <collection property="empList" ofType="Emp">
            <id property="eid" column="eid"/>
            <result property="empName" column="emp_name"/>
            <result property="age" column="age"/>
            <result property="sex" column="sex"/>
            <result property="email" column="email"/>
        </collection>
    </resultMap>

    <select id="getDeptAndEmp" resultMap="getDeptAndEmpResultMap">
        select * from t_dept left join t_emp on t_dept.did = t_emp.did where t_dept.did = #{did}
    </select>

测试方法

    @Test
    public void testGetDeptAndEmp(){
        SqlSession sqlSession = SqlSessionFactoryUtils.getSqlSession();
        DeptMapper deptMapper = sqlSession.getMapper(DeptMapper.class);
        Dept dept = deptMapper.getDeptAndEmp(1);
        System.out.println(dept);
        sqlSession.close();
    }

在这里插入图片描述

方式二:分布查询

查询部分信息

DeptMapper接口

 /**
     * 根据部分的did查询属于该部分的所有员工信息
     * @param did
     * @return
     */
    Dept getDeptAndEmpOne(@Param("did") Integer did);

DeptMapper接口对应的DeptMapper.xml配置文件

<!--Dept getDeptAndEmpOne(@Param("did") Integer did);-->
    <!--方式二:一对多,使用分布查询方式-->
    <resultMap id="getDeptAndEmpOneResultMap" type="Dept">
        <id property="did" column="did"/>
        <result property="deptName" column="dept_name"/>
        <collection property="empList"
                    select="com.atguigu.mapper.EmpMapper.getDeptAndEmpTwo"
                    column="did"/>
    </resultMap>

    <select id="getDeptAndEmpOne" resultMap="getDeptAndEmpOneResultMap">
        select * from t_dept where t_dept.did = #{did}
    </select>

查询员工信息

EmpMapper接口

 /**
     * 根据did查询员工集合
     * @param did
     * @return
     */
    List<Emp> getDeptAndEmpTwo(@Param("did") Integer did);

EmpMapper接口对应的EmpMapper.xml配置文件

 <!--List<Emp> getDeptAndEmpTwo(@Param("did") Integer did);-->
    <resultMap id="getDeptAndEmpTwoResultMap" type="Emp">
        <id property="eid" column="eid"/>
        <result property="empName" column="emp_name"/>
        <result property="age" column="age"/>
        <result property="email" column="email"/>
        <result property="sex" column="sex"/>
    </resultMap>

    <select id="getDeptAndEmpTwo" resultMap="getDeptAndEmpTwoResultMap">
        select * from t_emp where t_emp.did = #{did}
    </select>

测试方法

@Test
    public void testGetDeptAndEmpOne(){
        SqlSession sqlSession = SqlSessionFactoryUtils.getSqlSession();
        DeptMapper deptMapper = sqlSession.getMapper(DeptMapper.class);
        Dept dept = deptMapper.getDeptAndEmpOne(1);
        System.out.println(dept);
        sqlSession.close();
    }

在这里插入图片描述

6.延迟加载

  • 分步查询的优点:可以实现延迟加载,但是必须在核心配置文件中设置全局配置信息:
  • lazyLoadingEnabled:延迟加载的全局开关。当开启时,所有关联对象都会延迟加载
    • aggressiveLazyLoading:当开启时,任何方法的调用都会加载该对象的所有属性。 否则,每个属性会按需加载
  • 此时就可以实现按需加载,获取的数据是什么,就只会执行相应的sql。此时可通过association和collection中的fetchType属性设置当前的分步查询是否使用延迟加载,fetchType=“lazy(延迟加载)|eager(立即加载)”
<settings>
	<!--开启延迟加载-->
	<setting name="lazyLoadingEnabled" value="true"/>
</settings>
@Test
    public void testGetEmpAndDeptByStepTwoAndOne(){
        SqlSession sqlSession = SqlSessionFactoryUtils.getSqlSession();
        EmpMapper empMapper = sqlSession.getMapper(EmpMapper.class);
        Emp emp = empMapper.getEmpAndDeptByStepOne(4);
        System.out.println(emp.getEmpName());
        sqlSession.close();
    }
  • 关闭延迟加载,两条SQL语句都运行了
    在这里插入图片描述

  • 开启延迟加载,只运行获取emp的SQL语句
    在这里插入图片描述

    @Test
    public void testGetEmpAndDeptByStepTwoAndOne(){
        SqlSession sqlSession = SqlSessionFactoryUtils.getSqlSession();
        EmpMapper empMapper = sqlSession.getMapper(EmpMapper.class);
        Emp emp = empMapper.getEmpAndDeptByStepOne(4);
        System.out.println(emp.getEmpName());
        System.out.println("===============================");
        System.out.println(emp.getDept());
        sqlSession.close();
    }
  • 开启后,需要用到查询dept的时候才会调用相应的SQL语句
    在这里插入图片描述

  • fetchType当开启了全局的延迟加载之后,可以通过该属性手动控制延迟加载的效果,fetchType=“lazy(延迟加载)|eager(立即加载)”

<resultMap id="empAndDeptByStepResultMap" type="Emp">
	<id property="eid" column="eid"></id>
	<result property="empName" column="emp_name"></result>
	<result property="age" column="age"></result>
	<result property="sex" column="sex"></result>
	<result property="email" column="email"></result>
	<association property="dept"
				 select="com.atguigu.mybatis.mapper.DeptMapper.getEmpAndDeptByStepTwo"
				 column="did"
				 fetchType="lazy"></association>
</resultMap>

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/63531.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

html静态网站基于HTML+CSS+JavaScript上海美食介绍网站网页设计与实现共计5个页面

&#x1f380; 精彩专栏推荐&#x1f447;&#x1f3fb;&#x1f447;&#x1f3fb;&#x1f447;&#x1f3fb; ✍️ 作者简介: 一个热爱把逻辑思维转变为代码的技术博主 &#x1f482; 作者主页: 【主页——&#x1f680;获取更多优质源码】 &#x1f393; web前端期末大作业…

K邻近算法k值选取以及kd树概念、原理、构建方法、最近邻域搜索和案例分析

一、k值选择 K值过小&#xff1a;容易受到异常点的影响k值过大&#xff1a;受到样本均衡的问题 近似误差&#xff1a;对现有训练集的训练误差&#xff0c;关注训练集&#xff0c;如果近似误差过小可能会出现过拟合的现象&#xff0c;对现有的训练集能有很好的预测&#xff0c;…

基于RockyLinux8.7一键安装OpenStack Yoga版本

硬件环境 虚拟软件&#xff1a;vmware workstation16 操作系统&#xff1a;RockyLinux8 虚拟机硬件配置&#xff1a; CPU&#xff1a;2 memory&#xff1a;8G disk&#xff1a;80G net card&#xff1a;1个—VMnet8 ip/netmask&#xff1a;192.168.9.160/24 下载并安装RockyL…

python:最小二乘法拟合原理及代码实现

这里写目录标题原理代码实现原理 最小二乘法适用于对处理的一堆数据&#xff0c;不必精确的经过每一点&#xff0c;而是根据图像到每个数据点的距离和最小确定函数。需要注意的是&#xff0c;最小二乘是对全局进行拟合优化&#xff0c;对噪声比较敏感&#xff0c;所以如果有噪…

知识点7--Docker的容器命令

本篇为大家介绍Docker的容器命令&#xff0c;也顺带着让大家明白Docker和vmware都属于虚拟化技术下的软件&#xff0c;但是他们的不同之处不止在于运行的系统不同&#xff0c;他们的运行逻辑也不同&#xff0c;VMware是虚拟化完整的系统&#xff0c;而docker是隔离一个进程&…

03 - 调试环境的搭建(Bochs)(实验未完)

---- 整理自狄泰软件唐佐林老师课程 1. Bochs&#xff08;另一款优秀的虚拟机软件&#xff09; 专业模拟x86架构的虚拟机 开源且高度可移植&#xff0c;由C编写完成 支持操作系统开发过程中的断点调试 通过简单配置就能运行绝大多数主流的操作系统 2. Bochs的安装与配置 下载…

数字化升级里,RPA的下一步正在走向哪?

如果说&#xff0c;API这种能力在2021年并未成为“刚需”&#xff0c;那么在2022年其已经一跃成为RPA进入企业真正场景的“必需品”。 作者|斗斗 编辑|皮爷 出品|产业家 今年八月&#xff0c;调查机构Gartner发布了2022全球RPA魔力象限。 数据显示&#xff0c;2021年&a…

空间直接坐标系(XYZ)转经纬度(BLH)

本章首先介绍空间直角坐标系与大地坐标系&#xff0c;然后列出XYZ转换BLH的公式&#xff0c;最后基于C语言完成该部分代码设计。 参考书籍&#xff1a; 董大男&#xff0c;陈俊平&#xff0c;王解先等&#xff0c;GNSS高精度定位原理&#xff0c;科学出版社 黄丁发&#xff0c;…

图扑软件荣获第七届“创客中国”中小企业创新创业大赛优胜奖

2022 年 11 月 17 日&#xff0c;由工业和信息化部、财政部共同主办的第七届“创客中国”中小企业创新创业大赛全国总决赛在浙江杭州落下帷幕。 本次《第七届“创客中国”中小企业创新创业大赛》举办目的&#xff0c;意在加大优质中小企业梯度培育力度&#xff0c;进一步提升中…

高新技术企业如何规划

如何提高申报高企的成功率&#xff0c;应该是很多企业关心的一个问题。 2022年高新技术企业申报已经结束&#xff0c;今年第三批申报的企业结果也将公示&#xff0c;有客户会问&#xff0c;历年来你们申报高企通过率这么高&#xff0c;是怎么做到的&#xff1f; 那么现在呢&a…

《痞子衡嵌入式半月刊》 第 66 期

痞子衡嵌入式半月刊&#xff1a; 第 66 期 这里分享嵌入式领域有用有趣的项目/工具以及一些热点新闻&#xff0c;农历年分二十四节气&#xff0c;希望在每个交节之日准时发布一期。 本期刊是开源项目&#xff08;GitHub: JayHeng/pzh-mcu-bi-weekly&#xff09;&#xff0c;欢…

Spring 框架下如何调用kafka

1、Spring 项目代码结构如下&#xff1a; 2、数据库资源配置文件如下&#xff1a; #sql配置文件 spring.datasource.driver-class-namecom.microsoft.sqlserver.jdbc.SQLServerDriver #.19為測試地址&#xff0c;.13為正式地址 spring.datasource.urljdbc:sqlserver://172.12.…

[ 红队知识库 ] 常见防火墙(WAF)拦截页面

&#x1f36c; 博主介绍 &#x1f468;‍&#x1f393; 博主介绍&#xff1a;大家好&#xff0c;我是 _PowerShell &#xff0c;很高兴认识大家~ ✨主攻领域&#xff1a;【渗透领域】【数据通信】 【通讯安全】 【web安全】【面试分析】 &#x1f389;点赞➕评论➕收藏 养成习…

gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu交叉编译Arm Linux环境下的身份证读卡器so库操作步骤

1、配置环境变量 ①将gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu.tar解压至/home/eastcoms/ sudo或者root运行命令 &#xff1a;sudo tar -xvf gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu.tar -C /home/eastcoms .tar用 -xvf .gz用 -zxvf .bz2用 -jxvf …

easypoi导入案例

文章目录easypoi导入案例一、依赖二、导出模板1、excel模板实体类(同下)2、具体实现类3、easypoi工具类中的方法4、自定义样式类三、导入校验1、excel模板实体类2、具体实现类3、自定义信号导入校验类easypoi导入案例 一、依赖 <dependency><groupId>cn.afterturn…

第7 部分 HDLC 和PPP

路由器经常用于构建广域网&#xff0c;广域网链路的封装和以太网上的封装有着非常大的差别。常见的广域网封装有HDLC&#xff0c;PPP 和Frame-relay 等&#xff0c;本次介绍HDLC 和PPP。相对而言&#xff0c;PPP 比HDLC 有较多的功能。 7.1 HDLC 和PPP 简介 7.1.1 HDLC 介绍 H…

批处理及有状态等应用类型在 K8S 上应该如何配置?

众所周知, Kubernetes(K8S)更适合运行无状态应用, 但是除了无状态应用. 我们还会有很多其他应用类型, 如: 有状态应用, 批处理, 监控代理(每台主机上都得跑), 更复杂的应用(如:hadoop 生态...). 那么这些应用可以在 K8S 上运行么? 如何配置? 其实, K8S 针对这些都有对应的不…

操作系统:存储器管理 练习题(带有详细答案解析)

文章目录1.存储器的层次结构2.程序的装入和链接2.1.程序的装入2.2.程序的链接3.连续分配存储管理方式3.1.单一连续分配3.2.固定分区分配3.3.动态分区分配3.4.基于顺序搜索的动态分区分配算法3.5.基于索引搜索的动态分区分配算法3.6.动态可重定位分区分配4.对换4.1.多道程序环境…

SBT 树原理和实战

一 基本概念 SBT&#xff08;Size Balanced Tree&#xff0c;节点大小平衡树&#xff09;是一种自平衡二叉查找树&#xff0c;通过子树的大小来保持平衡。与红黑树、AVL 树等自平衡二叉查找树相比&#xff0c;SBT更易于实现。SBT 可以在 O (logn) 时间内完成所有二叉搜索树的相…

【考研】操作系统复习冲刺(2023年408)

前言 本文内容主要源自于王道讲解的学习笔记总结。梳理《操作系统》考点&#xff08;以理论为重点&#xff09;&#xff0c;并对重点内容划下横线和加粗标注&#xff0c;方便考研复习。 可搭配以下链接一起学习&#xff1a; 【考研复习】《操作系统原理》孟庆昌等编著课后习…