Mybatis 一对多延迟加载,并且子查询中与主表字段不对应 (19)
Mybatis 一对多延迟加载,并且子查询中与主表字段不对应应用说明。
实现一对多关联(懒加载),一个教研组对应多个教师,既:教师的教研编号与教研组的教研编号关联,并且教师关联教研组外键与教研组编号不一致。
1、工程资源配置文件
1)、本应用实际应用到了(开启延迟加载配置、关闭立即加载配置);
2) 、外关联查询语句对应xml文件 :<mapper resource="com/mybatis03/mapper/teacherGroupToTeacherMapper.xml"/>
3)、主查询xml文件:<mapper resource="com/mybatis03/mapper/TeacherMapper.xml"/>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration> <settings>
<!-- 开启日志,并制定使用的具体日志,LOG4J 对应 log4j.properties的文件名 -->
<setting name="logImpl" value="LOG4J"/>
<!-- 开启延迟加载 -->
<setting name="lazyLoadingEnabled" value="true"/>
<!-- g关闭立即加载 -->
<setting name="aggressiveLazyLoading" value="false"/>
</settings>
<!-- 转换器 -->
<typeHandlers>
<!-- 把java类的boolean类型转换数据 int,数据库int转换为java类的boolean类型 -->
<typeHandler handler="com.mybatis03.util.BooleanAndIntConverter" javaType="Boolean" jdbcType="INTEGER"/>
</typeHandlers>
<environments default="development">
<environment id="development">
<transactionManager type="JDBC"/>
<dataSource type="POOLED">
<property name="driver" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://127.0.0.1:3306/mybatis01"/>
<property name="username" value="root"/>
<property name="password" value="root"/>
</dataSource>
</environment>
</environments>
<mappers>
<!-- 加载映射文件 -->
<mapper resource="com/mybatis03/mapper/personMapper.xml"/>
<mapper resource="com/mybatis03/mapper/TeacherMapper.xml"/>
<mapper resource="com/mybatis03/mapper/teacherCourseMapper.xml"/>
<!-- 外关联查询语句对应xml文件 -->
<mapper resource="com/mybatis03/mapper/teacherGroupToTeacherMapper.xml"/>
</mappers>
</configuration>
2、mapper文件
2.1 教师.xml 文件
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.mybatis03.mapper.TeacherMapper">
<!-- 实现一对多关联(懒加载),一个教研组对应多个教师,既:教师的教研编号与教研组的教研编号关联 -->
<select id="queryWithLazyGroupAndTeachers" parameterType="int" resultMap="lazyGroupTeacherMap">
SELECT g.*,g.groupID AS groupno FROM teachergroup g
WHERE g.groupid =#{groupid}
</select>
<!--类和表对应关系 (一对多都用collection,一对一用 association) -->
<resultMap id="lazyGroupTeacherMap" type="com.mybatis03.bean.TeacherGroup">
<!-- 因为type主类是TeacherGroup,所以先配置 TeacherGroup类属性对应关系 -->
<id property="groupID" column="groupid" />
<result property="groupName" column="groupname"/>
<!-- 配置成员属性教师 ,一对多;属性类型:javaType,属性元素类型 ofType-->
<!--property 中的属性为实体类中的属性,column对应数据库中的字段 -->
<collection property="teacherList" ofType="com.mybatis03.bean.Teacher"
select="com.mybatis03.mapper.teacherGroupToTeacherMapper.queryGroupToTeacherByNO" column="groupno" >
</collection>
</resultMap>
</mapper>
说明:由于在关联过程中,教研组编号与教师编号不一致,通过重命名方式使。关联字段一致:
A、本应用实现懒加载使用原始SQL关联查询应为:SELECT g.*,t.* FROM teachergroup g INNER JOIN teacher t ON g.groupid = t.groupno WHERE g.groupid =#{groupid}
B、应用懒加载实现说明解决字段不一致参加红色浪线;
2.2 外关联查询教师信息xml文件
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<!--指定为接口的全类名-->
<mapper namespace="com.mybatis03.mapper.teacherGroupToTeacherMapper">
<!-- 查询教师,延迟加载应用此配置文件 -->
<!-- 查询教师对应的课程 -->
<select id="queryGroupToTeacherByNO" parameterType="int" resultType="com.mybatis03.bean.Teacher">
SELECT * FROM teacher WHERE groupno = #{groupno}
</select>
</mapper>
3、教师接口类
public interface TeacherMapper {
/* 实现一对多关联(延迟加载),一个教研组对应多个教师,既:教师的教研编号与教研组的教研编号关联 */
TeacherGroup queryWithLazyGroupAndTeachers(int groupNo);
}
4、实体类
4.1 教师实体类
public class Teacher {
@Override
public String toString() {
return "Teacher{" +
"teaNo=" + teaNo +
", courseNo=" + courseNo +
", teaName='" + teaName + '\'' +
", teacherCourse{" + "courseNo=" + teacherCourse.getCourseNo() +
", courseName=" + teacherCourse.getCourseName() +"}"+ '}';
} /* 教师编号 */
private int teaNo;
/* 课程编号 */
private int courseNo;
/* 教师名称 */
private String teaName; /* 教师课程类,课程作为老师属性 */
private TeacherCourse teacherCourse; /* 新增一个教研组编号,用于关联教研组编号,实现多对一关联*/
private int groupNo; /**
* <!--利用resultMap实现一对一 -->
* @return
*/
public TeacherCourse getTeacherCourse() {
return teacherCourse;
} public void setTeacherCourse(TeacherCourse teacherCourse) {
this.teacherCourse = teacherCourse;
} public int getGroupNo() {
return groupNo;
} public void setGroupNo(int groupNo) {
this.groupNo = groupNo;
} public int getCourseNo() {
return courseNo;
} public void setCourseNo(int courseNo) {
this.courseNo = courseNo;
} public int getTeaNo() {
return teaNo;
} public void setTeaNo(int teaNo) {
this.teaNo = teaNo;
} public String getTeaName() {
return teaName;
} public void setTeaName(String teaName) {
this.teaName = teaName;
}
}
4.2 教研组实体类
1 public class TeacherGroup {
2 @Override
3 public String toString() {
4
5 String str = "";
6 for (int i = 0; i < teacherList.size(); i++) {
7
8 str += "teaNo=" + teacherList.get(i).getTeaNo() + ",";
9 str += "courseNo=" + teacherList.get(i).getCourseNo() + ",";
10 str += "teaName=" + teacherList.get(i).getTeaName() + ",";
11 str += "groupNo=" + teacherList.get(i).getGroupNo();
12 if (i < teacherList.size() - 1) {
13 str += ",";
14 }
15
16 }
17 return "TeacherGroup{" +
18 "groupID=" + groupID +
19 ", groupName='" + groupName + '\'' +
20 ", teacherList{" +
21 // "teaNo=" + teacherList.get(0).getTeaNo() + "," +
22 // "courseNo=" + teacherList.get(0).getCourseNo() + "," +
23 // "teaName=" + teacherList.get(0).getTeaName() + "," +
24 // "groupNo=" + teacherList.get(0).getGroupNo() + "," +
25 str+
26 "}" +
27 '}';
28 }
29
30
31 /* 教研组编号:汉语教研组 1,英语教研组2,日语教研组3,德语教研组 4 */
32 /* 教研组编号,用于关联教师编号,实现多对一关联*/
33 private int groupID;
34
35 /* 教研组名称,英语教研组,日语教研组还是德语教研组*/
36 private String groupName;
37
38 /* 一个教研组对应多个教师,属于一对多关系。关联关系:教师的教研编号与教研组的教研编号关联 */
39 private List<Teacher> teacherList;
40
41 public List<Teacher> getTeacherList() {
42 return teacherList;
43 }
44
45 public void setTeacherList(List<Teacher> teacherList) {
46 this.teacherList = teacherList;
47 }
48
49 public int getGroupID() {
50 return groupID;
51 }
52
53 public void setGroupID(int groupID) {
54 this.groupID = groupID;
55 }
56
57 public String getGroupName() {
58 return groupName;
59 }
60
61 public void setGroupName(String groupName) {
62 this.groupName = groupName;
63 }
64 }
5、测试类
1 @Test
2 public void queryWithLazyGroupAndTeachers() throws Exception {
3 Reader reader = Resources.getResourceAsReader("mybatis-03.xml");
4 SqlSessionFactory sessionFactory = new SqlSessionFactoryBuilder().build(reader);
5
6 SqlSession session = sessionFactory.openSession();
7 int groupNo = 1;
8 TeacherMapper personMapper = session.getMapper(TeacherMapper.class);
9 TeacherGroup teacherGroup = personMapper.queryWithLazyGroupAndTeachers(groupNo);
10 System.out.println("教研组编号:"+teacherGroup.getGroupID()+",教研组名称:"+teacherGroup.getGroupName());
11 List<Teacher> teacherList = teacherGroup.getTeacherList();
12 for (Teacher teacher : teacherList) {
13 System.out.println("教师编号:"+teacher.getTeaNo()+",教师名称:"
14 +teacher.getTeaName()+",教研组编号:"+teacher.getGroupNo());
15 }
16 }
测试结果
"C:\Program Files\Java\jdk1.8.0_25\bin\java" -ea -Didea.test.cyclic.buffer.size=1048576 "-javaagent:C:\Users\newsoft\AppData\Roaming\JetBrains\IntelliJ IDEA 2017.3.5\lib\idea_rt.jar=1031:C:\Users\newsoft\AppData\Roaming\JetBrains\IntelliJ IDEA 2017.3.5\bin" -Dfile.encoding=UTF-8 -classpath "C:\Users\newsoft\AppData\Roaming\JetBrains\IntelliJ IDEA 2017.3.5\lib\idea_rt.jar;C:\Users\newsoft\AppData\Roaming\JetBrains\IntelliJ IDEA 2017.3.5\plugins\junit\lib\junit-rt.jar;C:\Users\newsoft\AppData\Roaming\JetBrains\IntelliJ IDEA 2017.3.5\plugins\junit\lib\junit5-rt.jar;D:\download\lib\mavenTollTransfer\mic-repository\org\junit\platform\junit-platform-launcher\1.5.2\junit-platform-launcher-1.5.2.jar;D:\download\lib\mavenTollTransfer\mic-repository\org\apiguardian\apiguardian-api\1.1.0\apiguardian-api-1.1.0.jar;D:\download\lib\mavenTollTransfer\mic-repository\org\junit\platform\junit-platform-engine\1.5.2\junit-platform-engine-1.5.2.jar;D:\download\lib\mavenTollTransfer\mic-repository\org\opentest4j\opentest4j\1.2.0\opentest4j-1.2.0.jar;D:\download\lib\mavenTollTransfer\mic-repository\org\junit\platform\junit-platform-commons\1.5.2\junit-platform-commons-1.5.2.jar;D:\download\lib\mavenTollTransfer\mic-repository\org\junit\jupiter\junit-jupiter-engine\5.5.2\junit-jupiter-engine-5.5.2.jar;D:\download\lib\mavenTollTransfer\mic-repository\org\junit\jupiter\junit-jupiter-api\5.5.2\junit-jupiter-api-5.5.2.jar;D:\download\lib\mavenTollTransfer\mic-repository\org\junit\vintage\junit-vintage-engine\5.5.2\junit-vintage-engine-5.5.2.jar;D:\download\lib\mavenTollTransfer\mic-repository\junit\junit\4.12\junit-4.12.jar;D:\download\lib\mavenTollTransfer\mic-repository\org\hamcrest\hamcrest-core\1.3\hamcrest-core-1.3.jar;C:\Program Files\Java\jdk1.8.0_25\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.8.0_25\jre\lib\deploy.jar;C:\Program Files\Java\jdk1.8.0_25\jre\lib\ext\access-bridge-64.jar;C:\Program Files\Java\jdk1.8.0_25\jre\lib\ext\cldrdata.jar;C:\Program Files\Java\jdk1.8.0_25\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.8.0_25\jre\lib\ext\jaccess.jar;C:\Program Files\Java\jdk1.8.0_25\jre\lib\ext\jfxrt.jar;C:\Program Files\Java\jdk1.8.0_25\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.8.0_25\jre\lib\ext\nashorn.jar;C:\Program Files\Java\jdk1.8.0_25\jre\lib\ext\sunec.jar;C:\Program Files\Java\jdk1.8.0_25\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jdk1.8.0_25\jre\lib\ext\sunmscapi.jar;C:\Program Files\Java\jdk1.8.0_25\jre\lib\ext\sunpkcs11.jar;C:\Program Files\Java\jdk1.8.0_25\jre\lib\ext\zipfs.jar;C:\Program Files\Java\jdk1.8.0_25\jre\lib\javaws.jar;C:\Program Files\Java\jdk1.8.0_25\jre\lib\jce.jar;C:\Program Files\Java\jdk1.8.0_25\jre\lib\jfr.jar;C:\Program Files\Java\jdk1.8.0_25\jre\lib\jfxswt.jar;C:\Program Files\Java\jdk1.8.0_25\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.8.0_25\jre\lib\management-agent.jar;C:\Program Files\Java\jdk1.8.0_25\jre\lib\plugin.jar;C:\Program Files\Java\jdk1.8.0_25\jre\lib\resources.jar;C:\Program Files\Java\jdk1.8.0_25\jre\lib\rt.jar;D:\ideaworkspace\ProjectStudy\mybatis-02\target\classes;D:\download\lib\mavenTollTransfer\mic-repository\org\hamcrest\hamcrest-core\2.1\hamcrest-core-2.1.jar;D:\download\lib\mavenTollTransfer\mic-repository\org\hamcrest\hamcrest\2.1\hamcrest-2.1.jar;D:\download\lib\mavenTollTransfer\mic-repository\org\mybatis\mybatis\3.4.5\mybatis-3.4.5.jar;D:\download\lib\mavenTollTransfer\mic-repository\mysql\mysql-connector-java\5.1.44\mysql-connector-java-5.1.44.jar;D:\download\lib\mavenTollTransfer\mic-repository\log4j\log4j\1.2.17\log4j-1.2.17.jar;D:\download\lib\mavenTollTransfer\mic-repository\org\slf4j\slf4j-log4j12\1.7.12\slf4j-log4j12-1.7.12.jar;D:\download\lib\mavenTollTransfer\mic-repository\org\slf4j\slf4j-api\1.7.30\slf4j-api-1.7.30.jar;D:\download\lib\mavenTollTransfer\mic-repository\cglib\cglib\3.3.0\cglib-3.3.0.jar;D:\download\lib\mavenTollTransfer\mic-repository\org\ow2\asm\asm\7.1\asm-7.1.jar;D:\download\lib\mavenTollTransfer\mic-repository\net\logstash\logback\logstash-logback-encoder\5.3\logstash-logback-encoder-5.3.jar;D:\download\lib\mavenTollTransfer\mic-repository\com\fasterxml\jackson\core\jackson-databind\2.10.3\jackson-databind-2.10.3.jar;D:\download\lib\mavenTollTransfer\mic-repository\com\fasterxml\jackson\core\jackson-annotations\2.10.3\jackson-annotations-2.10.3.jar;D:\download\lib\mavenTollTransfer\mic-repository\com\fasterxml\jackson\core\jackson-core\2.10.3\jackson-core-2.10.3.jar" com.intellij.rt.execution.junit.JUnitStarter -ideVersion5 -junit5 com.mybatis03.test.testTeacher01,queryWithLazyGroupAndTeachers
[lsjSso]2021-10-20 09:17:47,649-org.apache.ibatis.logging.LogFactory-0 [main]DEBUGorg.apache.ibatis.logging.LogFactory-Logging initialized using 'class org.apache.ibatis.logging.slf4j.Slf4jImpl' adapter.
[lsjSso]2021-10-20 09:17:47,753-org.apache.ibatis.logging.LogFactory-104 [main]DEBUGorg.apache.ibatis.logging.LogFactory-Logging initialized using 'class org.apache.ibatis.logging.log4j.Log4jImpl' adapter.
[lsjSso]2021-10-20 09:17:47,781-org.apache.ibatis.datasource.pooled.PooledDataSource-132 [main]DEBUGorg.apache.ibatis.datasource.pooled.PooledDataSource-PooledDataSource forcefully closed/removed all connections.
[lsjSso]2021-10-20 09:17:47,781-org.apache.ibatis.datasource.pooled.PooledDataSource-132 [main]DEBUGorg.apache.ibatis.datasource.pooled.PooledDataSource-PooledDataSource forcefully closed/removed all connections.
[lsjSso]2021-10-20 09:17:47,781-org.apache.ibatis.datasource.pooled.PooledDataSource-132 [main]DEBUGorg.apache.ibatis.datasource.pooled.PooledDataSource-PooledDataSource forcefully closed/removed all connections.
[lsjSso]2021-10-20 09:17:47,782-org.apache.ibatis.datasource.pooled.PooledDataSource-133 [main]DEBUGorg.apache.ibatis.datasource.pooled.PooledDataSource-PooledDataSource forcefully closed/removed all connections.
[lsjSso]2021-10-20 09:17:47,953-org.apache.ibatis.transaction.jdbc.JdbcTransaction-304 [main]DEBUGorg.apache.ibatis.transaction.jdbc.JdbcTransaction-Opening JDBC Connection
[lsjSso]2021-10-20 09:17:48,174-org.apache.ibatis.datasource.pooled.PooledDataSource-525 [main]DEBUGorg.apache.ibatis.datasource.pooled.PooledDataSource-Created connection 16503286.
[lsjSso]2021-10-20 09:17:48,174-org.apache.ibatis.transaction.jdbc.JdbcTransaction-525 [main]DEBUGorg.apache.ibatis.transaction.jdbc.JdbcTransaction-Setting autocommit to false on JDBC Connection [com.mysql.jdbc.JDBC4Connection@fbd1f6]
[lsjSso]2021-10-20 09:17:48,177-com.mybatis03.mapper.TeacherMapper.queryWithLazyGroupAndTeachers-528 [main]DEBUGcom.mybatis03.mapper.TeacherMapper.queryWithLazyGroupAndTeachers-==> Preparing: SELECT g.*,g.groupID AS groupno FROM teachergroup g WHERE g.groupid =?
[lsjSso]2021-10-20 09:17:48,211-com.mybatis03.mapper.TeacherMapper.queryWithLazyGroupAndTeachers-562 [main]DEBUGcom.mybatis03.mapper.TeacherMapper.queryWithLazyGroupAndTeachers-==> Parameters: 1(Integer)
[lsjSso]2021-10-20 09:17:48,257-com.mybatis03.mapper.TeacherMapper.queryWithLazyGroupAndTeachers-608 [main]DEBUGcom.mybatis03.mapper.TeacherMapper.queryWithLazyGroupAndTeachers-<== Total: 1
教研组编号:1,教研组名称:chinese
[lsjSso]2021-10-20 09:17:48,258-com.mybatis03.mapper.teacherGroupToTeacherMapper.queryGroupToTeacherByNO-609 [main]DEBUGcom.mybatis03.mapper.teacherGroupToTeacherMapper.queryGroupToTeacherByNO-==> Preparing: SELECT * FROM teacher WHERE groupno = ?
[lsjSso]2021-10-20 09:17:48,258-com.mybatis03.mapper.teacherGroupToTeacherMapper.queryGroupToTeacherByNO-609 [main]DEBUGcom.mybatis03.mapper.teacherGroupToTeacherMapper.queryGroupToTeacherByNO-==> Parameters: 1(Integer)
[lsjSso]2021-10-20 09:17:48,261-com.mybatis03.mapper.teacherGroupToTeacherMapper.queryGroupToTeacherByNO-612 [main]DEBUGcom.mybatis03.mapper.teacherGroupToTeacherMapper.queryGroupToTeacherByNO-<== Total: 2
教师编号:1001,教师名称:sara,教研组编号:1
教师编号:1002,教师名称:sakula,教研组编号:1 Process finished with exit code 0
说明:
Mybatis 一对多延迟加载,并且子查询中与主表字段不对应 (19)的更多相关文章
- 子查询中的NULL问题
子查询返回有单行,多行和null值:适用于单行子查询的比较运算符是=,>,>=,<,<=<>和!=.适用于多行子查询的比较运算符是in,not in,any和any ...
- SQLSERVER 子查询中使用ORDER BY
SQLSERVER如何在子查询中使用ORDER BY 今天在使用公司的一个pager接口的时候,需要传递一个查询的SQL语句,因为我希望他能够在pager对他查询出来的结果排序之前自己先进行排序, 于 ...
- SQLSERVER如何在子查询中使用ORDER BY
今天在使用公司的一个pager接口的时候,需要传递一个查询的SQL语句,因为我希望他能够在pager对他查询出来的结果排序之前自己先进行排序, 于是在这个SQL中添加了ORDER BY,但是得到的结果 ...
- Mysql in子查询中加limit报错
Mysql in子查询中加limit报错 select id from aa where id in ( select id from bb limit 10 ); 改写成 SELECT id FRO ...
- oracle查询包含在子表中的主表数据
Oracle数据库,查询某表中包含在子表中的数据,子表中数据按特定条件来源于该父表,SQL命令如 ) a_table父表,b_table子表,a和b表都有commandId列,a表的commandId ...
- Oracle子查询中any、some、all之间的区别
用some,any和all对子查询中返回的多行结果进行处理. 下面我们来简单介一下这几个关键词的含义. * Some在此表示满足其中一个的意义,是用or串起来的比较从句. * Any也表示满足其中一个 ...
- oracle 子查询中null的问题(in 和 not in)
这里的in后面的句子可以理解为or拼接,简单举例即 in (9566,9839,null)可以等价于mgr=9566 or mgr=9839 or mgr=null, not in (9566,983 ...
- mysql更新子查询中的内容
UPDATE t_finance_certify_copy c SET c.biz_type=2,c.sub_biz_type=18WHERE c.finance_certify_id IN(SELE ...
- mybatis一对多关系的关联查询
问题描述:实现两张表的关联查询 学生表: 班级表: 要实现学生管理信息中有所在班级的名称,即如下图所示 1.对应学生表的pojo类写全班级表中的字段(适用于要连接的表字段较少的情况) sql语句直接在 ...
随机推荐
- nginx简介,使用
nginx是什么 nginx是一个开源的,支持高性能,高并发的www服务和代理服务软件. 支持高并发,能支持几万并发连接 资源消耗少,在3万并发连接下开启10个nginx线程消耗的内存不到200M 可 ...
- uniapp H5 打包并部署到 nginx
个人也是了百度了挺久的了,花费的时间( 俩个半小时 ) uniapp 的打包首先要先配置,配置好了才能去进行打包,如图所示. 这只是第一步. 注意: 1.运行基础路径最好用 ./ ,如果配置了其他请自 ...
- iNeuOS工业互联平台,增加OPC UA驱动,同步和订阅方式读取数据
目 录 1. 概述... 1 2. 平台演示... 2 3. OPC UA应用效果... 2 1. 概述 最近的项目,用户需要使用OPC UA读取数据,通 ...
- client-go实战之二:RESTClient
欢迎访问我的GitHub https://github.com/zq2599/blog_demos 内容:所有原创文章分类汇总及配套源码,涉及Java.Docker.Kubernetes.DevOPS ...
- 痞子衡嵌入式:MCUXpresso IDE下工程链接文件配置管理与自动生成机制
大家好,我是痞子衡,是正经搞技术的痞子.今天痞子衡给大家介绍的是MCUXpresso IDE下工程链接文件配置管理与自动生成机制. 痞子衡在 2018 年初写过一个专题 <嵌入式开发文件系列&g ...
- Java基础(二)——内部类
一.内部类 内部类(Inner Class)就是定义在一个类里面的类.与之对应,包含内部类的类被称为外部类.内部类可以用private修饰. 1.为什么要定义内部类?或者内部类的作用是什么? 内部类提 ...
- jq 追加元素的几种方法
jQuery添加插入元素技巧: jquery添加分为在指定元素的里面添加和外面添加两种: 里面添加使用(append 和prepend) 里面添加又分为在里面的前面添加和后面添加 里面的前面添加使用 ...
- k8s资源管理(基础操作)
1. 基础 本文实操基于k8s 1.22.1 # 可以查看资源分配情况 kubectl describe node # 全局资源情况查看 kubectl api-resources 1.1 apply ...
- java中各个类相互调用资源的原理
当我们要进行跨类的调用/使用的时候,比如当前类调用另一个类中的变量或方法时, 这时需要一定的条件,如果那些将要被调用的变量或方法是static(静态)变量,也叫类变 量,那么可以通过类名调用,相 ...
- Redis核心原理与实践--列表实现原理之quicklist结构
在上一篇文章<Redis列表实现原理之ziplist结构>,我们分析了ziplist结构如何使用一块完整的内存存储列表数据. 同时也提出了一个问题:如果链表很长,ziplist中每次插入或 ...