性用品微商做的最好的网站/全球外贸b2b网站
文章目录
- Mybatis 多对一 and 一对多查询详解
- 数据库
- 需求
- Mybatis代码
- 注意
Mybatis 多对一 and 一对多查询详解
数据库
员工表 t_emp
部门表 t_dept
CREATE TABLE `t_emp` (`emp_id` int NOT NULL AUTO_INCREMENT,`emp_name` varchar(25) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,`age` int DEFAULT NULL,`gender` varchar(25) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,`dept_id` int DEFAULT NULL,PRIMARY KEY (`emp_id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;CREATE TABLE `t_dept` (`dept_id` int NOT NULL AUTO_INCREMENT,`dept_name` varchar(25) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,PRIMARY KEY (`dept_id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;INSERT INTO `t_emp` (`emp_id`, `emp_name`, `age`, `gender`, `dept_id`) VALUES (1, '张三', 20, '男', 1), (2, '李四', 22, '男', 2), (3, '王五', 23, '男', 3), (4, '赵六', 24, '男', 1);INSERT INTO `t_dept` (`dept_id`, `dept_name`) VALUES (1, 'A'), (2, 'B'), (3, 'C');
需求
多对一:员工表对应部门表
查询指定id的员工以及其对应的部门
一对多:部门表对应员工表
查询指定的部门以及其包含的员工
Mybatis代码
DeptMapper接口文件
package com.atguigu.mybatis.mapper;import com.ruanjian.pojo.Dept;
import com.ruanjian.pojo.Emp;
import org.apache.ibatis.annotations.Param;import java.util.List;public interface DeptMapper {// 一对多查询// 查询部门表中的员工信息// 需要在部门类中添加员工的集合 private List<Emp> emps;Dept getDeptAndEmpById(@Param("deptId") Integer deptId);// 分步查询// 1.先查出指定id的部门信息,部门信息中有对应员工的dept_idDept getDeptAndEmpByStepOne(@Param("deptId") int deptId);// 2.再根据dept_id查出相对应的员工信息List<Emp> getDeptAndEmpByStepTwo(@Param("deptId") int deptId);}
EmpMapper接口文件
package com.atguigu.mybatis.mapper;
import com.ruanjian.pojo.Dept;
import com.ruanjian.pojo.Emp;
import org.apache.ibatis.annotations.Param;public interface EmpMapper {// 多对一查询// 查询指定id员工以及该员工所对应的部门信息Emp getEmpAndDeptById(@Param("empId") Integer empId);Emp getEmpAndDeptById_association(@Param("empId") Integer empId);// 分步查询// 先从员工表中查询出指定id的员工的数据,该数据中有对应部门id// 再根据部门id从部门表中查询出对应的部门信息// 分步查询第一步Emp getEmpAndDeptByIdOne(@Param("empId") Integer empId);// 分步查询第二步Dept getEmpAndDeptByIdTwo(@Param("deptId") Integer deptId);
}
Dept类文件 部门实体类
package com.ruanjian.pojo;/*
员工对部门 是多对一,多对一是在多的那个类(员工类)中添加一个部门对象
部门对员工 是一对多,一对多是在一的那个类中(部门类)中添加一个员工集合对一 对的就是一个对象
对多 对的就是一个集合*/import java.util.List;// 部门实体类
public class Dept {private Integer deptId;private String deptName;private List<Emp> emps; // 添加的一个员工的集合public Dept() {}public Dept(Integer deptId, String deptName) {this.deptId = deptId;this.deptName = deptName;}public Integer getDeptId() {return deptId;}public void setDeptId(Integer deptId) {this.deptId = deptId;}public String getDeptName() {return deptName;}public void setDeptName(String deptName) {this.deptName = deptName;}public List<Emp> getEmps() {return emps;}public void setEmps(List<Emp> emps) {this.emps = emps;}@Overridepublic String toString() {return "Dept{" +"deptId=" + deptId +", deptName='" + deptName + '\'' +", emps=" + emps +'}';}
}
Emp类文件
员工实体类
package com.ruanjian.pojo;/*
员工对部门 是多对一,多对一是在多的那个类(员工类)中添加一个部门对象
部门对员工 是一对多,一对多是在一的那个类中(部门类)中添加一个员工集合对一 对的就是一个对象
对多 对的就是一个集合*/// 员工实体类// 对一就是对应的一个对象
// 对多就是对应的一个集合
public class Emp {private Integer empId;private String empName;private Integer age;private String gender;private Dept dept; // 加上一个部门的对象public Emp() {}public Emp(Integer empId, String empName, Integer age, String gender) {this.empId = empId;this.empName = empName;this.age = age;this.gender = gender;}public Integer getEmpId() {return empId;}public void setEmpId(Integer empId) {this.empId = empId;}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 getGender() {return gender;}public void setGender(String gender) {this.gender = gender;}public Dept getDept() {return dept;}public void setDept(Dept dept) {this.dept = dept;}@Overridepublic String toString() {return "Emp{" +"empId=" + empId +", empName='" + empName + '\'' +", age=" + age +", gender='" + gender + '\'' +", dept=" + dept +'}';}
}
DeptMapper
<?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="com.atguigu.mybatis.mapper.DeptMapper"><!-- 处理一对多的映射关系1. collection2. 分步查询
-->
<!--*************************** 一对多 collection ****************************************--><resultMap id="deptAndEmpById_resultMap" type="dept"><id column="dept_id" property="deptId"></id><result column="dept_name" property="deptName"></result><!-- collection : 处理一对多的映射关系(处理集合类型的属性)--><!-- ofType表示的是集合中的类型--><collection property="emps" ofType="Emp"><id column="emp_id" property="empId"></id><result column="emp_name" property="empName"></result><result column="age" property="age"></result><result column="gender" property="gender"></result></collection></resultMap><!-- Dept getDeptAndEmpById(@Param("deptId") Integer deptId);--><select id="getDeptAndEmpById" resultMap="deptAndEmpById_resultMap">select *from t_deptleft join t_emp on t_dept.dept_id = t_emp.dept_idwhere t_dept.dept_id=#{deptId}</select><!--*************************** 一对多 collection ****************************************--><!--*************************** 一对多 分步查询 ****************************************--><resultMap id="deptAndEmpResultMapByStep" type="Dept"><id column="dept_id" property="deptId"></id><result column="dept_name" property="deptName"></result><collection property="emps"select="com.atguigu.mybatis.mapper.DeptMapper.getDeptAndEmpByStepTwo"column="dept_id"></collection></resultMap><!-- Dept getDeptAndEmpByStepOne(@Param("deptId") int deptId);// 先查出指定id的部门信息,部门信息中有对应员工的dept_id --><select id="getDeptAndEmpByStepOne" resultMap="deptAndEmpResultMapByStep">select * from t_dept where dept_id = #{deptId}</select><!-- List<Emp> getDeptAndEmpByStepTwo(@Param("deptId") int deptId);// 再根据dept_id查出相对应的员工信息--><select id="getDeptAndEmpByStepTwo" resultType="Emp">select * from t_emp where dept_id = #{deptId}</select></mapper>
EmpMapper
<?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="com.atguigu.mybatis.mapper.EmpMapper"><!--处理多对一的映射关系有三种方法:第一种:级联方式处理第二种:association 处理多对一的映射关系(处理的是实体类类型的属性)第三种:分布查询--><!-- ************ 第一种:级联方式处理 *************** --><resultMap id="EmpAndDeptById_resultMap" type="Emp"><id column="emp_id" property="empId"></id><result column="emp_name" property="empName"></result><result column="age" property="age"></result><result column="gender" property="gender"></result><result column="dept_id" property="dept.deptId"></result><result column="dept_name" property="dept.deptName"></result></resultMap><!--Emp getEmpAndDeptById(@Param("empId") Integer empId);--><select id="getEmpAndDeptById" resultMap="EmpAndDeptById_resultMap">select *from t_empleft join t_dept on t_emp.dept_id = t_dept.dept_idwhere t_emp.emp_id=#{empId}</select><!-- *********************************************--><!-- *************** 第二种 association ******************************--><!-- 第二种 association--><resultMap id="getEmpAndDeptById_association_resultMap" type="Emp"><id column="emp_id" property="empId"></id><result column="emp_name" property="empName"></result><result column="age" property="age"></result><result column="gender" property="gender"></result><!--association: 处理多对一的映射关系(处理实体类类型的属性)property: 设置需要处理映射关系的属性的属性名javaType: 设置要处理的属性的类型, 就是把<association>标签下设置映射关系的字段,封装给某个类--><association property="dept" javaType="Dept"><id column="dept_id" property="deptId"></id><result column="dept_name" property="deptName"></result></association></resultMap><!-- Emp getEmpAndDeptById_association(@Param("empId") Integer empId);--><select id="getEmpAndDeptById_association" resultMap="getEmpAndDeptById_association_resultMap">select *from t_empleft join t_dept on t_emp.dept_id = t_dept.dept_idwhere t_emp.emp_id=#{empId}</select><!-- *********************************************--><!-- ****************** 第三种:分布查询 ***************************--><resultMap id="getEmpAndDeptByIdOne_resultMap" type="Emp"><id column="emp_id" property="empId"></id><result column="emp_name" property="empName"></result><result column="age" property="age"></result><result column="gender" property="gender"></result><!--property: 设置需要处理映射关系的属性的属性名select: 填写分步查询的sql的唯一标识,就是设置下一步要执行的sql语句column: 将上一个sql查询出的某个字段作为分步查询的下一个sql语句sql条件,相当于函数的参数,传给下一个sql语句fetchType: 在开启了延时加载的环境中,通过该属性设置当前的分步查询是否使用延迟加载有两个值:eager(立即加载) lazy(延迟加载)--><association property="dept"fetchType="eager"select="com.atguigu.mybatis.mapper.EmpMapper.getEmpAndDeptByIdTwo"column="dept_id"></association></resultMap><!-- Emp getEmpAndDeptByIdOne(@Param("empId") Integer empId);--><select id="getEmpAndDeptByIdOne" resultMap="getEmpAndDeptByIdOne_resultMap">select * from t_emp where emp_id = #{empId}</select><!-- Dept getEmpAndDeptByIdTwo(@Param("deptId") Integer deptId);--><select id="getEmpAndDeptByIdTwo" resultType="Dept">select * from t_dept where dept_id = #{deptId}</select><!-- *********************************************--></mapper>
ResultMapTest
import com.atguigu.mybatis.mapper.DeptMapper;
import com.atguigu.mybatis.mapper.EmpMapper;
import com.ruanjian.pojo.Dept;
import com.ruanjian.pojo.Emp;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;import java.io.IOException;public class ResultMapTest {private SqlSession session;/*处理多对一的映射关系有三种方法:第一种:级联方式处理第二种:association 处理多对一的映射关系(处理的是实体类类型的属性)第三种:分步查询*/// *********************** 多对一 ****************************************@Test// 第三种:分步查询public void textGetEmpAndDeptByIdOne() {EmpMapper mapper = session.getMapper(EmpMapper.class);Emp emp = mapper.getEmpAndDeptByIdOne(1);System.out.println(emp);}@Test// 第二种:associationpublic void textGetEmpAndDeptById_association() {EmpMapper mapper = session.getMapper(EmpMapper.class);Emp emp = mapper.getEmpAndDeptById_association(2);System.out.println(emp);}@Test// 第一种:级联方式处理public void textGetEmpAndDeptById() {EmpMapper mapper = session.getMapper(EmpMapper.class);Emp emp = mapper.getEmpAndDeptById(2);System.out.println(emp);}// *********************** 一对多 ****************************************@Test// 分步查询public void textGetDeptAndEmpByStep() {DeptMapper mapper = session.getMapper(DeptMapper.class);Dept dept = mapper.getDeptAndEmpByStepOne(2);System.out.println(dept);}@Test// 一对多查询public void textGetDeptAndEmpById() {DeptMapper mapper = session.getMapper(DeptMapper.class);Dept dept = mapper.getDeptAndEmpById(1);System.out.println(dept);}// ***************************************************************// junit会在每一个@Test方法前执行@Before方法@Beforepublic void init() throws IOException {session = new SqlSessionFactoryBuilder().build(Resources.getResourceAsStream("mybatis-config.xml")).openSession();}// junit会在每一个@Test方法后执行@After方法@Afterpublic void clear() {session.commit();session.close();}
}
db.properties
mysql.driver=com.mysql.cj.jdbc.Driver
mysql.url=jdbc:mysql://localhost:3306/mybatis?serverTimezone=UTC&characterEncoding=utf8&useUnicode=true&useSSL=false
mysql.username=root
mysql.password=123456
log4j.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"><log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"><appender name="STDOUT" class="org.apache.log4j.ConsoleAppender"><param name="Encoding" value="UTF-8"/><layout class="org.apache.log4j.PatternLayout"><param name="ConversionPattern" value="%-5p %d{MM-dd HH:mm:ss,SSS} %m (%F:%L) \n"/></layout></appender><logger name="java.sql"><level value="debug"/></logger><logger name="org.apache.ibatis"><level value="info"/></logger><root><level value="debug"/><appender-ref ref="STDOUT"/></root>
</log4j:configuration>
mybatis-config.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configurationPUBLIC "-//mybatis.org//DTD Config 3.0//EN""http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration><!--环境配置--><!--引入外部db.properties--><properties resource="db.properties"/><settings><!-- <setting name="cacheEnabled" value="true" />--><!-- 开启延时加载--><setting name="lazyLoadingEnabled" value="true"/><!-- 开启时即为true时任何方法的调用都会加载相关类的全部属性false时是按需加载,true是全部加载--><setting name="aggressiveLazyLoading" value="false"/><setting name="mapUnderscoreToCamelCase" value="true"/></settings><typeAliases><package name="com.ruanjian.pojo"/></typeAliases><!--配置mybatis的连接环境(可以配置多个环境)--><environments default="development"><!--开发环境--><environment id="development"><!--使用JDBC事务管理--><transactionManager type="JDBC"/><!--数据库连接相关配置,db.properties文件中的内容--><!--使用连接池技术--><dataSource type="POOLED"><!--数据库驱动--><property name="driver" value="${mysql.driver}"/><!--连接字符串--><property name="url" value="${mysql.url}"/><!--数据库用户名--><property name="username" value="${mysql.username}"/><!--数据库密码--><property name="password" value="${mysql.password}"/></dataSource></environment></environments><!--mapping文件路径配置--><mappers><!-- <mapper resource="mapper/DeptMapper.xml"/>--><package name="com.atguigu.mybatis.mapper"/></mappers>
</configuration>
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><groupId>com.itheima</groupId><artifactId>MyBaits_2</artifactId><version>1.0-SNAPSHOT</version><build><plugins><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><configuration><source>8</source><target>8</target></configuration></plugin></plugins></build><properties><maven.compiler.sourece>11</maven.compiler.sourece><maven.compiler.target>11</maven.compiler.target><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding></properties><dependencies><dependency><groupId>org.mybatis</groupId><artifactId>mybatis</artifactId><version>3.5.2</version></dependency><dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId><version>8.0.11</version><scope>runtime</scope></dependency><dependency><groupId>junit</groupId><artifactId>junit</artifactId><version>4.12</version><scope>text</scope></dependency><!-- log4j日志 --><dependency><groupId>log4j</groupId><artifactId>log4j</artifactId><version>1.2.17</version></dependency></dependencies>
</project>
注意
新建包时用点
例如:com.atguigu.mybatis.mapper
resources目录下建立多层目录的时候时是用分割线
例如:com/atguigu/mybatis/mapper
mybatis-config.xml文件中
<package name="com.atguigu.mybatis.mapper"/>
<package>的使用条件:
接口文件要和xml文件同名,并且在同一个目录下
使用注解写的接口,只能有class的方式注册,例:
<mapper class="com.atguigu.mybatis.mapper.DeptMapper"></mapper>
相关文章:

Mybatis 多对一和一对多查询
文章目录 Mybatis 多对一 and 一对多查询详解数据库需求Mybatis代码注意 Mybatis 多对一 and 一对多查询详解 数据库 员工表 t_emp 部门表 t_dept CREATE TABLE t_emp (emp_id int NOT NULL AUTO_INCREMENT,emp_name varchar(25) CHARACTER SET utf8 COLLATE utf8_general_ci…...

MySQL的数据库操作、数据类型、表操作
目录 一、数据库操作 (1)、显示数据库 (2)、创建数据库 (3)、删除数据库 (4)、使用数据库 二、常用数据类型 (1)、数值类型 (2࿰…...

音视频技术开发周刊 | 317
每周一期,纵览音视频技术领域的干货。 新闻投稿:contributelivevideostack.com。 MIT惊人再证大语言模型是世界模型!LLM能分清真理和谎言,还能被人类洗脑 MIT等学者的「世界模型」第二弹来了!这次,他们证明…...

【JavaSE专栏58】“Java构造函数:作用、类型、调用顺序和最佳实践“ ⚙️⏱️
解析Java构造函数:作用、类型、调用顺序和最佳实践" 🚀📚🔍🤔📝🔄⚙️⏱️📖🌐 摘要引言1. 什么是构造函数 🤔2. 构造函数的类型与用途 📝1.…...

Ubuntu系统HUSTOJ 用 vim 修改php.ini 重启PHP服务
cd / sudo find -name php.ini 输出: ./etc/php/7.4/cli/php.ini ./etc/php/7.4/fpm/php.ini sudo vim /etc/php/7.4/cli/php.ini sudo vim /etc/php/7.4/fpm/php.ini 知识准备: vim的搜索与替换 在正常模式下键入 / ,即可进入搜索模式…...

案例分析真题-信息安全
案例分析真题-信息安全 2009年真题 【问题1】 【问题2】 【问题3】 2010年真题 【问题1】 【问题2】 【问题3】 2011 年真题 【问题1】 【问题2】 【问题3】 骚戴理解:这个破题目完全考的知识储备,不知道的连手都动不了,没法分析 2013年真题…...

envi5.3处理高分二号影像数据辐射定标大气校正
目录 一、多光谱影像处理 1. 辐射定标 2.大气校正 1. 需要准备一些数据: 2.大气校正过程 3、正射校正 二、全色影像处理 1. 辐射定标 2. 正射校正 三、图像融合 1.几何配准 2.图像融合 高分二号处理流程 envi5.3的安装教程: ENVI5.3安装 安装完ENVI5.3后࿰…...

C语言 结构体
结构体的自引用: 自引用的目的: 结构体的自引用就是指在结构体内部,包含指向自身类型结构体的指针。 像链表就会用到结构体的自引用。假如我们要创建链表 链表的没个节点都是一个结构体,它里面存放着它的数据和下个节点的地址。 假如我们用…...

frp-内网穿透部署-ubuntu22服务器-windows server-详细教程
文章目录 1.下载frp2.配置服务器2.1.配置frps.ini文件2.2.设置服务文件2.3.设置开机自启和服务操作2.4.后台验证2.5.服务器重启 3.配置本地window3.1.frpc配置3.2.添加开机计划启动3.3.控制台启动隐藏窗口 4.centos防火墙和端口3.1.开放端口3.2.查看端口 5.关闭进程5.1.杀死进程…...

MySQL内存使用的监控开关和使用查看
参考文档: https://brands.cnblogs.com/tencentcloud/p/11151 https://www.cnblogs.com/grasp/p/10306697.html MySQL如何使用内存 在MySQL中,内存占用主要包括以下几部分,全局共享的内存、线程独占的内存、内存分配器占用的内存࿰…...

数据库管理-第113期 Oracle Exadata 04-硬件选择(20231020)
数据库管理-第113期 Oracle Exadata 04-硬件选择(2023010290) 本周没写文章,主要是因为到上海参加了Oracle CAB/PAB会议,这个放在后面再讲,本期讲一讲Exadata,尤其是存储节点的硬件选择及其对应的一些通用…...

带着问题去分析:Spring Bean 生命周期 | 京东物流技术团队
1: Bean在Spring容器中是如何存储和定义的 Bean在Spring中的定义是_org.springframework.beans.factory.config.BeanDefinition_接口,BeanDefinition里面存储的就是我们编写的Java类在Spring中的元数据,包括了以下主要的元数据信息: 1&…...

C语言修行之函数篇(一)tolower —— 转换为小写字母
文章目录 函数说明函数声明函数返回值函数实现函数实例 函数说明 对于大写字母,如果在当前语言环境中存在小写表示形式,则tolower()返回其小写等效物。否则,tolower()函数执行相同的任务。 函数声明 #include <ctype.h> int tolower(…...

【JavaSE专栏55】Java集合类HashTable解析
🌲Java集合类HashTable解析 🌲Java集合类HashTable解析摘要引言Hashtable是什么?Hashtable vs. HashMap:何时使用Hashtable?多线程环境:历史遗留系统:不需要进行特殊操作: Hashtable…...

Apollo上机实践:一次对自动驾驶技术的亲身体验
上机实践 概述自动驾驶通信分布式系统开发模式开发工具 自动驾驶感知传感器特性感知流程及算法部署感知模型 自动驾驶决策规划决策规划流程和算法使用 Dreamview 进行控制在环的规划调试开发规划场景和算法 福利活动 主页传送门:📀 传送 概述 Apollo 是…...

QTcpServer简单的TCP服务器连接
1、简介 简单实现控制TCP服务器获取连接的套接字。点击断开服务器即可关闭所有连接,最大连接数量为5个。 声明源文件 #include "mainwindow.h"MainWindow::MainWindow(QWidget *parent): QMainWindow(parent) {//设置固定大小setFixedSize(1024,600);b…...

LeetCode热题100——双指针
双指针 1.移动零2.盛最多水的容器3.三数之和 1.移动零 给定一个数组 nums,编写一个函数将所有 0 移动到数组的末尾,同时保持非零元素的相对顺序。 // 题解:使用双指针,其中快指针指向非零元素,慢指针指向首个零元素下…...

Ubuntu ARMv8编译Qt源码以及QtCreator
最近需要在NVIDIA小盒子上面跑一个程序,一开始想着在Ubuntu x64下交叉编译一版,后来发现libqxcb.so 这个库在configure时就会一直报错,多方查找怀疑可能是由于硬件不支持在x64环境下编译AMR架构的xcb库。 所以最后在ARM下直接编译Qt源码了&am…...

虚机Centos忘记密码如何重置
1进入开机前的页面,选中第一个,按“e”键,进入编辑模式 2找到ro crashkernel项,将ro替换成 rw initsysroot/bin/sh 3 Ctrlx mount -o remount, rw / chroot /sysroot chroot /sysroot passwd root 输入两次密码 touch /.a…...

OpenGL_Learn02
1. 监听窗口,绑定回调函数 #include <glad/glad.h> #include <GLFW/glfw3.h> #include <iostream>void framebuffer_size_callback(GLFWwindow* window, int width, int height) {glViewport(0, 0, width, height);std::cout << "变了…...

基于STC系列单片机实现外部中断0控制按键调节定时器0产生PWM(脉宽调制)的功能
#define uchar unsigned char//自定义无符号字符型为uchar #define uint unsigned int//自定义无符号整数型为uint sbit PwmOut P1^0;//位定义脉宽调制输出为单片机P1.0脚 uchar PwmTimeCount;//声明脉宽调制时间计数变量 uchar PwmDutyCycle;//声明脉宽调制占空比变量 void Ti…...

vue3中 reactive和ref的区别
在Vue 3中,reactive和ref都是用于响应式数据的API。它们的主要区别在于使用方式和返回值类型。 reactive: reactive函数用于将一个对象转换为响应式对象。它接收一个普通的JavaScript对象,并返回一个被代理的响应式对象。这意味着当响应式对…...

docker的安装部署nginx和mysql
小白自己整理,如有错误请指示! 自我理解:docker就是把应用程序所用的依赖程序,函数库等相关文件打包成镜像文件,类似系统光盘,然后可以在任意电脑上安装使用(方便运维人员部署程序)…...

测试C#调用Aplayer播放视频(1:加载Aplayer控件)
微信公众号“Dotnet跨平台”的文章《开源精品,使用 C# 开发的 KTV 点歌项目》中使用了迅雷开源APlayer播放引擎。最近在学习有哪些能拿来播放视频的组件或控件,于是准备试试,根据文章中的介绍,在迅雷APlayer播放引擎网站中下载了A…...

二叉树的遍历+二叉树的基本操作
文章目录 二叉树的操作一、 二叉树的存储1.二叉树的存储结构 二、 二叉树的基本操作1.前置创建一棵二叉树:1. 定义结点 2.简单的创建二叉树 2.二叉数的遍历1.前序遍历2.中序遍历3.后序遍历4.层序遍历 3.二叉树的操作1.获取树中节点的个数2.获取叶子节点的个数3.获取…...

Go 语言gin框架的web
节省时间与精力,更高效地打造稳定可靠的Web项目:基于Go语言和Gin框架的完善Web项目骨架。无需从零开始,直接利用这个骨架,快速搭建一个功能齐全、性能优异的Web应用。充分发挥Go语言和Gin框架的优势,轻松处理高并发、大…...

Docker底层原理:Cgroup V2的使用
文章目录 检查 cgroup2 文件系统是否已加载检查系统是否已挂载 cgroup2 文件系统创建 cgroup2 层次结构查看 cgroup2 开启的资源控制类型启用 cgroup2 资源控制设置 cgroup2 资源限制加入进程到 cgroup2 检查 cgroup2 文件系统是否已加载 cat /proc/filesystems | grep cgroup…...

历年上午真题笔记(2014年)
解析:A 网络设计的三层模型 : 接入层:Layer 2 Switching,最终用户被许可接入网络的点,用户通过接入层可以访问网络设备。 汇聚层:Layer2/3 Switching,访问层设备的汇聚点,负责汇接配线单元,利用二、三层技术实现工作组分段及网络故障的隔离,以免对核心层网络设备造…...

数据库软考知识
分布式数据库透明性 封锁 加上共享锁之后只能加共享锁,加上排他锁之后,啥锁都不能加。 分布式数据库特性 伪传递定理 SQL函数定义,有点冷 来了奥,更冷 存储过程 很重要,下午第二大题也是数据库...

学习笔记|配对样本均数T检验|SPSS常用的快捷键|规范表达|《小白爱上SPSS》课程:SPSS第六讲 | 配对样本均数T检验
目录 学习目的软件版本原始文档配对样本均数T检验一、实战案例二、案例解析三、统计策略四、SPSS操作1、正态性检验2、配对样本T检验 五、结果解读六、规范报告1、规范表格2、规范文字 划重点Tips:SPSS常用的快捷键 学习目的 SPSS第六讲 | 配对样本均数T检验 软件版本 IBM S…...