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

Mybatis【分页插件,缓存,一级缓存,二级缓存,常见缓存面试题】

文章目录

  • MyBatis缓存
    • 分页
    • 延迟加载和立即加载
      • 什么是立即加载?
      • 什么是延迟加载?
      • 延迟加载/懒加载的配置
    • 缓存
      • 什么是缓存?
      • 缓存的术语
      • 什么是MyBatis 缓存?
      • 缓存的适用性
      • 缓存的分类
      • 一级缓存
        • 引入案例
        • 一级缓存的配置
        • 一级缓存的工作流程
        • 一级缓存失效的情况
      • 二级缓存
        • XML实现
        • 注解实现
        • 二级缓存的缺点
    • 自定义缓存的分类
    • 总结(面试题汇总):

MyBatis缓存

分页

在Mybatis的配置文件中进行声明该插件:

<?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><properties resource="jdbc.properties"></properties><typeAliases><!-- 给单个类起别名 --><!-- <typeAlias alias="Student" type="bean.Student"/> --><!-- 批量别名定义,包扫描,别名为类名,扫描整个包下的类 --><package name="bean" /></typeAliases><!-- 分页插件 --><plugins><plugin interceptor="com.github.pagehelper.PageInterceptor"></plugin></plugins><environments default="development"><environment id="development"><transactionManager type="JDBC" /><dataSource type="POOLED"><property name="driver" value="${jdbc.driver}" /><property name="url" value="${jdbc.url}" /><property name="username" value="${jdbc.username}" /><property name="password" value="${jdbc.password}" /></dataSource></environment></environments><mappers><!-- 注册sqlmapper文件 --><!-- 1.同包 接口和sqlMapper 2.同名 接口和sqlMapper 3.sqlMapper的namespace指向接口的类路径 --><!-- <mapper resource="mapper/StudentMapper.xml" /> --><!-- <mapper class="mapper.StudentMapper"/> --><package name="mapper" /></mappers>
</configuration>
	// 逻辑分页,减少对磁盘的读取,但是占用内存空间大@Select("select * from student")public List<Student> findStudentRowBounds(RowBounds rb);// 分页插件(推荐)@Select("select * from student")public List<Student> findStudentPageHelper();

方式1: 使用Map集合来保存分页需要数据,来进行分页

package mapper;
public interface StudentMapper {// 物理分页,多次读取磁盘,占用内存小@Select("select * from student limit #{cpage},#{size}")public List<Student> selectLimit(@Param("cpage") int cpage, @Param("size") int size);
}
package test;
public class Test01 {public static void main(String[] args) {SqlSession sqlSession = DaoUtil.getSqlSession();StudentMapper studentMapper = sqlSession.getMapper(StudentMapper.class);List<Student> list = studentMapper.selectLimit((1 - 1) * 3, 3);list.forEach(System.out::println);DaoUtil.closeSqlSession(sqlSession);}
}

在这里插入图片描述
方式2: 使用RowBounds集合来保存分页需要数据,来进行分页

package mapper;
public interface StudentMapper {// 逻辑分页,减少对磁盘的读取,但是占用内存空间大@Select("select * from student")public List<Student> findStudentRowBounds(RowBounds rb);
}
package test;
public class Test01 {public static void main(String[] args) {SqlSession sqlSession = DaoUtil.getSqlSession();StudentMapper studentMapper = sqlSession.getMapper(StudentMapper.class);RowBounds rb = new RowBounds((1 - 1) * 3, 3);List<Student> list = studentMapper.findStudentRowBounds(rb);list.forEach(System.out::println);DaoUtil.closeSqlSession(sqlSession);}
}

在这里插入图片描述
方式3: 使用分页插件来进行分页【推荐】

package mapper;
public interface StudentMapper {// 分页插件(推荐)@Select("select * from student")public List<Student> findStudentPageHelper();
}
package test;
public class Test01 {public static void main(String[] args) {SqlSession sqlSession = DaoUtil.getSqlSession();StudentMapper studentMapper = sqlSession.getMapper(StudentMapper.class);// PageHelper分页插件// (页码,每页多少个)// 分页第一页少做一次计算,sql语句也不同Page<Object> page = PageHelper.startPage(10, 1);// 获取page对象System.out.println(page);List<Student> list = studentMapper.findStudentPageHelper();// 详细分页对象PageInfo<Student> pageinfo = new PageInfo<Student>(list, 10);System.out.println(pageinfo);list.forEach(System.out::println);DaoUtil.closeSqlSession(sqlSession);}
}

在这里插入图片描述
在这里插入图片描述

延迟加载和立即加载

什么是立即加载?

立即加载是: 不管用不用信息,只要调用,马上发起查询并进行加载

比如: 当我们查询学生信息时,就需要知道学生在哪个班级中,所以就需要立马去查询班级的信息

通常:当 一对一或者 多对一 的时候需要立即加载

什么是延迟加载?

延迟加载是: 在真正使用数据时才发起查询,不用的时候不查询,按需加载(也叫 懒加载)

比如: 在查询班级信息,每个班级都会有很多的学生(假如每个班有100个学生),如果我们只是查看 班级信息,但是学生对象也会加载到内存中,会造成浪费。 所以我门需要进行懒加载,当确实需要查看班级中的学生信息,我门在进行加载班级中的学生信息。

通常: 一对多,或者多对多的是需要使用延迟加载

延迟加载/懒加载的配置

在这里插入图片描述
如果设置 lazyLoadingEnabled = false,则禁用延迟加载,会级联加载所有关联对象的数据

如果设置 lazyLoadingEnabled = true,默认情况下mybatis 是按层级延时加载的。

aggressiveLazyLoading = true,mybatis 是按层级延时加载 aggressiveLazyLoading = false,mybatis 按需求加载。

延迟加载的sqlmap
在这里插入图片描述

实现:

StudentMapper

@Results({ @Result(column = "classid", property = "classid"),@Result(column = "classid", property = "clazz", one = @One(select = "mapper.ClazzMapper.selectAll")) })@Select("select * from student")public List<Student> findStudentAndClassid();

测试类

public class Test02 {public static void main(String[] args) {SqlSession sqlSession = DaoUtil.getSqlSession();StudentMapper studentMapper = sqlSession.getMapper(StudentMapper.class);List<Student> list = studentMapper.findStudentAndClassid();Student stu = list.get(0);System.out.println(stu);
//		list.forEach(System.out::println);DaoUtil.closeSqlSession(sqlSession);}
}

发现这里执行了多条sql,但是我只需要List集合中第一个学生的所有数据
在这里插入图片描述
这里就需要进行懒加载!

将上面的StudentMapper改为:

// mybatis底层默认立即加载// FetchType.DEFAULT 从配置文件进行读取加载// FetchType.EAGER 立即加载// FetchType.LAZY 延迟加载,懒加载@Results({ @Result(column = "classid", property = "classid"),@Result(column = "classid", property = "clazz", one = @One(select = "mapper.ClazzMapper.selectAll", fetchType = FetchType.LAZY)) })@Select("select * from student")public List<Student> findStudentAndClassid();

在这里插入图片描述

就解决了查询一个Student而执行了多条SQL的问题

缓存

什么是缓存?

缓存(cache),数据交换的缓冲区,当应用程序需要读取数据时,先从数据库中将数据取出,放置在缓冲区中,应用程序从缓冲区读取数据。

在这里插入图片描述

特点:数据库取出的数据保存在内存中,具备快速读取和使用。
限制:读取时无需再从数据库获取,数据可能不是最新的;导致数据不一致性。

缓存的术语

针对缓存数据:

命中 需要的数据在缓存中找到结果。
未命中 需要的数据在缓存中未找到,重新获取。

在这里插入图片描述

什么是MyBatis 缓存?

功能 减少Java Application 与数 据库的交互次数,从而提升程 序的运行效率;
方式 通过配置和定制。

缓存的适用性

适合使用缓存: 经常查询并且不经常改变的 数据的正确与否对最终结果影响不大的 比如:一个公司的介绍,新闻等
不适合用于缓存: 经常改变的数据 数据的正确与否对最终结果影响很大 比如商品的库存,股市的牌价等

缓存的分类

在这里插入图片描述

一级缓存

将数据放在SqlSession对象中,一般默认开启一级缓存

在这里插入图片描述

引入案例

StudentMapper

@Select("select * from student where sid=#{v}")public Student findStudentBySid(int sid);

测试类

情况1:

SqlSession sqlSession = DaoUtil.getSqlSession();
StudentMapper stuMapper = sqlSession.getMapper(StudentMapper.class);
Student s1 = stuMapper.findStudentBySid(10);
System.out.println(s1);
System.out.println();
Student s2 = stuMapper.findStudentBySid(10);
System.out.println(s1 == s2);//true
DaoUtil.closeSqlSession(sqlSession);

在这里插入图片描述
从同一个SqlSession的一级缓存中拿的Student是同一个对象

情况2:从两个SqlSession的一级缓存中查询同一个对象,返回的不是同一个Student对象

【发生了一级缓存失效】

SqlSession sqlSession1 = DaoUtil.getSqlSession();
StudentMapper stuMapper1 = sqlSession1.getMapper(StudentMapper.class);
Student s1 = stuMapper1.findStudentBySid(10);
System.out.println(s1);
for (int i = 0; i < 100; i++) {System.out.print(".");
}
System.out.println();
SqlSession sqlSession2 = DaoUtil.getSqlSession();
StudentMapper stuMapper2 = sqlSession2.getMapper(StudentMapper.class);Student s2 = stuMapper2.findStudentBySid(10);
System.out.println(s2);System.out.println(s1 == s2);// false

在这里插入图片描述
情况3:

清空SQLSession后,查询的不是同一个Student对象

【发生了一级缓存失效】

SqlSession sqlSession = DaoUtil.getSqlSession();
StudentMapper stuMapper = sqlSession.getMapper(StudentMapper.class);
Student s1 = stuMapper.findStudentBySid(10);
System.out.println(s1);
for (int i = 0; i < 100; i++) {System.out.print(".");
}
System.out.println();
sqlSession.clearCache();//清空SqlSession()
Student s2 = stuMapper.findStudentBySid(10);
System.out.println(s2);
System.out.println(s1 == s2);// false
DaoUtil.closeSqlSession(sqlSession);

在这里插入图片描述
关闭sqlsession 或者清空sqlsession缓存都可以实现

注意:当调用sqlsession的修改,添加,删除,commit(),close() 等方法时, 就会清空一级缓存

一级缓存的配置

在这里插入图片描述

一级缓存的工作流程

在这里插入图片描述
在这里插入图片描述

一级缓存失效的情况

1.不同SqlSession对应不同的一级缓存
2.同一个SqlSession单查询条件不同
3.同一个SqlSession两次查询期间执行了任何一次增删改操作
4.同一个SqlSession两次查询期间手动清空了缓存

案例:

MappertStudent

@Insert("insert into student(sname) values (#{sname})")
public int addStudent(Student s);
@Select("select * from student where sid=#{v}")
public Student findStudentBySid(int sid);
package test;import java.util.List;import org.apache.ibatis.session.SqlSession;import bean.Student;
import dao.DaoUtil;
import mapper.StudentMapper;public class Test03 {public static void main(String[] args) {SqlSession sqlSession = DaoUtil.getSqlSession();StudentMapper stuMapper = sqlSession.getMapper(StudentMapper.class);Student s1 = stuMapper.findStudentBySid(10);System.out.println(s1);for (int i = 0; i < 100; i++) {System.out.print(".");}stuMapper.addStudent(new Student());System.out.println();
//		sqlSession.clearCache();//清空SqlSession()Student s2 = stuMapper.findStudentBySid(10);System.out.println(s2);System.out.println(s1 == s2);// false}
}

在这里插入图片描述
这里在两个查询之间进行了插入insert数据操作,就使一级缓存失效了,第二次查询的数据不是从缓存中拿,而是从数据库中去查询。

二级缓存

在这里插入图片描述
在这里插入图片描述

二级缓存就是在SqlSessionFactory,然后通过同一个Factory工厂,去获得相同的Cache,通过namespace去拿到对应的Student对象

XML实现

在mybatis中进行配置的参数说明:
在这里插入图片描述

<?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><properties resource="jdbc.properties"></properties><settings><!-- 全局启用或者禁用延迟加载<setting name=" lazyLoadingEnabled" value="true" />当启用时有延迟加载属性的对象会在被调用时按需进行加载,如果设置为false,会按层级进行延迟加载,默认为true<setting name=" aggressiveLazyLoading" value="true" /> --><setting name="cacheEnabled" value="true"/></settings><typeAliases><!-- 给单个类起别名 --><!-- <typeAlias alias="Student" type="bean.Student"/> --><!-- 批量别名定义,包扫描,别名为类名,扫描整个包下的类 --><package name="bean" /></typeAliases><environments default="development"><environment id="development"><transactionManager type="JDBC" /><dataSource type="POOLED"><property name="driver" value="${jdbc.driver}" /><property name="url" value="${jdbc.url}" /><property name="username" value="${jdbc.username}" /><property name="password" value="${jdbc.password}" /></dataSource></environment></environments><mappers><!-- 注册sqlmapper文件 --><!-- 1.同包 接口和sqlMapper 2.同名 接口和sqlMapper 3.sqlMapper的namespace指向接口的类路径 --><!-- <mapper resource="mapper/StudentMapper.xml" /> --><!-- <mapper class="mapper.StudentMapper"/> --><package name="mapper" /></mappers>
</configuration>

step1:

设置为true

<settings><!-- 全局启用或者禁用延迟加载<setting name=" lazyLoadingEnabled" value="true" />当启用时有延迟加载属性的对象会在被调用时按需进行加载,如果设置为false,会按层级进行延迟加载,默认为true<setting name=" aggressiveLazyLoading" value="true" /> --><setting name="cacheEnabled" value="true"/></settings>

step2:

表明这个映射文件开启了二级缓存

<cache/>

step3:

useCache="true"表明这条查询用到了二级缓存

<select id="findStudent" parameterType="int"resultType="student" useCache="true">select * from student where sid = #{value}</select>

在这里插入图片描述

注解实现

在这里插入图片描述
step1:

<?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><properties resource="jdbc.properties"></properties><settings><!-- 全局启用或者禁用延迟加载<setting name=" lazyLoadingEnabled" value="true" /><setting name=" aggressiveLazyLoading" value="true" /> --><setting name="cacheEnabled" value="true"/></settings><typeAliases><!-- 给单个类起别名 --><!-- <typeAlias alias="Student" type="bean.Student"/> --><!-- 批量别名定义,包扫描,别名为类名,扫描整个包下的类 --><package name="bean" /></typeAliases><environments default="development"><environment id="development"><transactionManager type="JDBC" /><dataSource type="POOLED"><property name="driver" value="${jdbc.driver}" /><property name="url" value="${jdbc.url}" /><property name="username" value="${jdbc.username}" /><property name="password" value="${jdbc.password}" /></dataSource></environment></environments><mappers><!-- 注册sqlmapper文件 --><!-- 1.同包 接口和sqlMapper 2.同名 接口和sqlMapper 3.sqlMapper的namespace指向接口的类路径 --><!-- <mapper resource="mapper/StudentMapper.xml" /> --><!-- <mapper class="mapper.StudentMapper"/> --><package name="mapper" /></mappers>
</configuration>

step2:

在接口前面加上@CacheNamespace(blocking = true),表示这个接口中的所有查询都是二级缓存

package mapper;
//让此处的所有内容都为二级缓存
@CacheNamespace(blocking = true)
public interface StudentMapper {@Select("select * from student where sid=#{v}")public Student findStudentBySid(int sid);
}

案例:

说明使用到了二级缓存,需要实体类实现序列化接口
在这里插入图片描述
在这里插入图片描述
序列化后的两个student对象不是同一个对象,二级缓存的数据存在磁盘上。
在这里插入图片描述

二级缓存的缺点

当数据库服务器和客户端是通过网络传输的,这里用二级缓存是为了减少由于网络环境不好加载时间。主要是为了解决数据库不在本机,且网络不稳定带来的问题,但是现在不推荐使用

1.Mybatis 的二级缓存相对于一级缓存来说, 实现了缓存数据的共享,可控性也更强;
2.极大可能会出现错误数据,有设计上的缺陷, 安全使用的条件比较苛刻;
3.分布式环境下,必然会出现读取到错误 数据,所以不推荐使用。

分布式就是同一个数据库连接多台服务器,给多个用户服务。二级缓存在分布式情况下必然会出错,二级缓存绝对不可能用。
在这里插入图片描述

但是现在基本不用,弊端如下:
在这里插入图片描述

案例完整代码:

bean.Student实体类

package bean;import java.io.Serializable;
import java.util.Date;public class Student implements Serializable{private int sid;private String sname;private Date birthday;private String Ssex;private int classid;private Clazz clazz;public int getSid() {return sid;}public void setSid(int sid) {this.sid = sid;}public String getSname() {return sname;}public void setSname(String sname) {this.sname = sname;}public Date getBirthday() {return birthday;}public void setBirthday(Date birthday) {this.birthday = birthday;}public String getSsex() {return Ssex;}public void setSsex(String ssex) {Ssex = ssex;}public int getClassid() {return classid;}public void setClassid(int classid) {this.classid = classid;}public Clazz getClazz() {return clazz;}public void setClazz(Clazz clazz) {this.clazz = clazz;}public Student(int sid, String sname, Date birthday, String ssex, int classid, Clazz clazz) {super();this.sid = sid;this.sname = sname;this.birthday = birthday;Ssex = ssex;this.classid = classid;this.clazz = clazz;}public Student() {super();}@Overridepublic String toString() {return "Student [sid=" + sid + ", sname=" + sname + ", birthday=" + birthday + ", Ssex=" + Ssex + ", classid="+ classid + ", clazz=" + clazz + "]";}
}

Daoutil工具类

package dao;import java.io.IOException;
import java.io.InputStream;import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;public class DaoUtil {static SqlSessionFactory factory = null;static {try {// 1.读取配置文件InputStream is = Resources.getResourceAsStream("mybatis-config.xml");// 2.生产sqlSession的工厂factory = new SqlSessionFactoryBuilder().build(is);} catch (IOException e) {// TODO Auto-generated catch blocke.printStackTrace();}}public static SqlSession getSqlSession() {// 3.返回sqlSession对象return factory.openSession();}public static void closeSqlSession(SqlSession sqlSession) {// 4.释放资源sqlSession.close();}
}

StudentMapper

package mapper;import java.util.List;
import java.util.Map;import org.apache.ibatis.annotations.CacheNamespace;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.One;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.jdbc.SQL;
import org.apache.ibatis.mapping.FetchType;
import org.apache.ibatis.session.RowBounds;import bean.Student;//让此处的所有内容都为二级缓存
@CacheNamespace(blocking = true)
public interface StudentMapper {@Insert("insert into student(sname) values (#{sname})")public int addStudent(Student s);// 物理分页,多次读取磁盘,占用内存小@Select("select * from student limit #{cpage},#{size}")public List<Student> selectLimit(@Param("cpage") int cpage, @Param("size") int size);// 逻辑分页,减少对磁盘的读取,但是占用内存空间大@Select("select * from student")public List<Student> findStudentRowBounds(RowBounds rb);// 分页插件(推荐)@Select("select * from student")public List<Student> findStudentPageHelper();// mybatis底层默认立即加载// FetchType.DEFAULT 从配置文件进行读取加载// FetchType.EAGER 立即加载// FetchType.LAZY 延迟加载,懒加载@Results({ @Result(column = "classid", property = "classid"),@Result(column = "classid", property = "clazz", one = @One(select = "mapper.ClazzMapper.selectAll", fetchType = FetchType.LAZY)) })@Select("select * from student")public List<Student> findStudentAndClassid();@Select("select * from student where sid=#{v}")public Student findStudentBySid(int sid);
}

测试类

package test;import org.apache.ibatis.session.SqlSession;import bean.Student;
import dao.DaoUtil;
import mapper.StudentMapper;public class Test04 {public static void main(String[] args) {SqlSession sqlSession1 = DaoUtil.getSqlSession();StudentMapper stuMapper1 = sqlSession1.getMapper(StudentMapper.class);Student s1 = stuMapper1.findStudentBySid(10);System.out.println(s1);DaoUtil.closeSqlSession(sqlSession1);SqlSession sqlSession2 = DaoUtil.getSqlSession();StudentMapper stuMapper2 = sqlSession2.getMapper(StudentMapper.class);Student s2 = stuMapper2.findStudentBySid(10);System.out.println(s1);DaoUtil.closeSqlSession(sqlSession2);}
}

自定义缓存的分类

在这里插入图片描述

总结(面试题汇总):

一级缓存和二级缓存的区别:

一级缓存指的是一个对象存到了SqlSession里面了,它是内存式的缓存,写在内存上的

二级缓存指的是缓存在SqlSessionFactory里面了,它是写在磁盘上的

二级缓存不用的原因:

分布式环境下,必然会出现读取到错误 数据,所以不推荐使用。

分页查询

什么是缓存

​ • 数据交换的缓冲区,当应用程序需要读取数据时,先从数据库中将数据取出,放置在缓冲区中,应用程序从缓冲区读取数据;

什么是一级缓存

​ • 相对同一个 SqlSession 对象而言的缓存;

什么是二级缓存

​ • 一个 namespace 下的所有操作语句,都影响着同一个Cache;

自定义缓存的方式

​ • 实现 org. apache. ibatis. cache. Cache 接口自定义缓存;

​ • 引入 Redis 等第三方内存库作为 MyBatis 缓存。
补充:
缓存击穿、雪崩、穿透
缓存击穿、雪崩、穿透

相关文章:

Mybatis【分页插件,缓存,一级缓存,二级缓存,常见缓存面试题】

文章目录 MyBatis缓存分页延迟加载和立即加载什么是立即加载&#xff1f;什么是延迟加载&#xff1f;延迟加载/懒加载的配置 缓存什么是缓存&#xff1f;缓存的术语什么是MyBatis 缓存&#xff1f;缓存的适用性缓存的分类一级缓存引入案例一级缓存的配置一级缓存的工作流程一级…...

【Qt开发】QT6.5.3安装方法(使用国内源)亲测可行!!!

目录 &#x1f315;下载在线安装包&#x1f315; 把安装包放到系统盘&#x1f315;开始安装&#x1f315;参考文章 &#x1f315;下载在线安装包 https://mirrors.nju.edu.cn/qt/official_releases/online_installers/ &#x1f315; 把安装包放到系统盘 我的系统盘是G盘&…...

springblade-JWT认证缺陷漏洞CVE-2021-44910

漏洞成因 SpringBlade前端通过webpack打包发布的&#xff0c;可以从其中找到app.js获取大量接口 然后直接访问接口&#xff1a;api/blade-log/api/list 直接搜索“请求未授权”&#xff0c;定位到认证文件&#xff1a;springblade/gateway/filter/AuthFilter.java 后面的代码…...

Chapter 12 Vue CLI脚手架组件化开发

欢迎大家订阅【Vue2Vue3】入门到实践 专栏&#xff0c;开启你的 Vue 学习之旅&#xff01; 文章目录 前言一、项目目录结构二、组件化开发1. 组件化2. Vue 组件的基本结构3. 依赖包less & less-loader 前言 组件化开发是Vue.js的核心理念之一&#xff0c;Vue CLI为开发者提…...

Ubuntu: 配置OpenCV环境

从从Ubuntu系统安装opencv_ubuntu安装opencv-CSDN博客文章浏览阅读2.3k次&#xff0c;点赞4次&#xff0c;收藏14次。开源计算机视觉(OpenCV)是一个主要针对实时计算机视觉的编程函数库。OpenCV的应用领域包括:2D和3D功能工具包、运动估计、面部识别系统、手势识别、人机交互、…...

芯片解决方案--SL8541e-OpenHarmony适配方案

摘要 本文描述8541E芯片适配OpenHarmony的整体方案。 本文描述的整体方案&#xff0c;不止适用于8541e&#xff0c;也适用于该芯片厂家的其他芯片&#xff0c;如7863、7885&#xff0c;少部分子系统会略有差异。 整体方案架构 整体方案架构如下图&#xff0c;遵循OpenHarmo…...

Spring Boot之数据访问集成入门

Spring Boot中的数据访问和集成支持功能是其核心功能之一&#xff0c;通过提供大量的自动配置和依赖管理&#xff0c;极大地简化了数据访问层的开发。Spring Boot支持多种数据库&#xff0c;包括关系型数据库&#xff08;如MySQL、Oracle等&#xff09;和非关系型数据库&#x…...

Learn ComputeShader 09 Night version lenses

这次将要制作一个类似夜视仪的效果 第一步就是要降低图像的分辨率&#xff0c; 这只需要将id.xy除上一个数字然后再乘上这个数字 可以根据下图理解&#xff0c;很明显通过这个操作在多个像素显示了相同的颜色&#xff0c;并且很多像素颜色被丢失了&#xff0c;自然就会有降低分…...

Java学习第七天

成员方法分类&#xff1a; 静态成员方法&#xff08;有static修饰 属于类&#xff09;建议用类名访问&#xff0c;也可以用对象访问 实例成员方法&#xff08;无static修饰 属于对象&#xff09;只能用对象出发访问 使用static来定义一些工具类 工具类直接使用类名.方法调用即…...

深入剖析 Redis 基础及其在 Java 应用中的实战演练

引言 在现代分布式系统和高并发应用中&#xff0c;缓存系统是不可或缺的一环&#xff0c;而 Redis 作为一种高性能的内存数据存储以其丰富的数据结构和快速的读写性能&#xff0c;成为了众多开发者的首选。本篇博客将详细介绍 Redis 的基础知识&#xff0c;并通过 Java 代码演…...

Why I‘m getting 404 Resource Not Found to my newly Azure OpenAI deployment?

题意&#xff1a;为什么我新部署的Azure OpenAI服务会出现404资源未找到的错误&#xff1f; 问题背景&#xff1a; Ive gone through this quickstart and I created my Azure OpenAI resource created a model deployment which is in state succeedded. I also playaround …...

【word导出带图片】使用docxtemplater导出word,通知书形式的word

一、demo-导出的的 二、代码操作 1、页面呈现 项目要求&#xff0c;所以页面和导出来的word模版一致 2、js代码【直接展示点击导出的js代码】 使用插件【先下载这五个插件&#xff0c;然后页面引入插件】 import docxtemplater from docxtemplater import PizZip from pizzip …...

微信小程序路由跳转之间的区别

navigateTo&#xff1a; 功能描述&#xff1a; navigateTo用于保留当前页面&#xff0c;跳转到应用内的某个页面。但是不能跳到 tabbar 页面。 页面栈变化&#xff1a; 当使用navigateTo进行页面跳转时&#xff0c;当前页面会被推入页面栈中&#xff0c;但不会被销毁&#xff0…...

centos安装docker并配置加速器

docker安装与卸载&#xff1a; 1、检查当前是否安装docker yum list installed | grep docker2、卸载docker 根据yum list installed | grep docker查询出来的内容&#xff0c;逐个进行删除 yum remove docker.x86 64 -y3、启动与关闭docker 4、删除/etc/docker文件夹 如果…...

【软件测试】设计测试用例

目录 &#x1f4d5;引言 &#x1f340;测试用例 &#x1f6a9;概念 &#x1f6a9;设计测试用例的万能公式 &#x1f3c0;常规思考逆向思维发散性思维 &#x1f3c0;万能公式 &#x1f384;设计测试用例的方法 &#x1f6a9;基于需求的设计方法 &#x1f3c0;明确需求中…...

Kafka【十三】消费者消费消息的偏移量

偏移量offset是消费者消费数据的一个非常重要的属性。默认情况下&#xff0c;消费者如果不指定消费主题数据的偏移量&#xff0c;那么消费者启动消费时&#xff0c;无论当前主题之前存储了多少历史数据&#xff0c;消费者只能从连接成功后当前主题最新的数据偏移位置读取&#…...

Python 的语法元素(容易忘记的)

文章目录 同步赋值同步赋值的相关操作同步赋值的原理 同步赋值 同步赋值是 Python 语言的一个强大功能&#xff0c;它让代码更加紧凑和高效&#xff0c;尤其是在处理多个变量时。 同步赋值的相关操作 简单同步赋值&#xff1a; 如果你想同时初始化多个变量到不同的值&#x…...

找到字符串中所有字母异位词问题

欢迎跳转我的主页&#xff1a;羑悻的小杀马特-CSDN博客 目录&#xff1a; 一题目简述&#xff1a; 二思路汇总&#xff1a; 三解答代码&#xff1a; 一题目简述&#xff1a; leetcode题目链接&#xff1a;. - 力扣&#xff08;LeetCode&#xff09; 二思路汇总&#xff1a; …...

QEMU用户模式测试AARCH64程序

QEMU的两种模式 QEMU&#xff08;快速模拟器&#xff09;是一个开源的机器模拟器和虚拟化器&#xff0c;它能够模拟多种处理器架构&#xff0c;并且可以在不同平台上运行。QEMU 支持两种模式&#xff1a;用户模式和系统模式。 用户模式&#xff08;User Mode&#xff09;&…...

机器学习(五) -- 监督学习(8) --神经网络2

机器学习系列文章目录及序言深度学习系列文章目录及序言 上篇&#xff1a;机器学习&#xff08;五&#xff09; -- 监督学习&#xff08;8&#xff09; --神经网络1 下篇&#xff1a; 前言 tips&#xff1a;标题前有“***”的内容为补充内容&#xff0c;是给好奇心重的宝宝看…...

DAMO-YOLO多模态实践:视觉+文本联合分析系统

DAMO-YOLO多模态实践&#xff1a;视觉文本联合分析系统 你有没有遇到过这样的情况&#xff1f;一个智能摄像头能认出画面里是“一辆车”&#xff0c;但它不知道这是“一辆正在送货的快递车”。或者&#xff0c;一个内容审核系统能识别出图片里有“文字”&#xff0c;却无法判断…...

1990-2025年企业基金退出事件数据

数据介绍 企业投资机构通过公开招募&#xff0c;并购&#xff0c;同行转售等退出方式转让基金份额、底层项目股权、IPO、回购、清算等方式&#xff0c;从所投基金或项目中收回资金、实现收益或止损离场的完整交易与流程。 数据整理1990至2025年企业基金退出事件数据&#xff…...

Vue项目调试神器Code-Inspector-Plugin全适配指南:从Vite、Webpack到Nuxt.js

Vue项目调试神器Code-Inspector-Plugin全适配指南&#xff1a;从Vite、Webpack到Nuxt.js 在Vue生态中&#xff0c;开发效率的提升往往依赖于工具的精准选择。当项目规模扩大、组件层级加深时&#xff0c;如何在浏览器中快速定位到源代码中的对应位置&#xff0c;成为影响开发体…...

MTK新工程创建与调试全攻略,人形机器人的发展历程、技术演进与未来图景。

MTK调试&#xff1a;创建新工程指南 准备工作 确保已安装MTK官方开发环境&#xff0c;包括SDK、驱动程序和必要的工具链。下载最新版本的MTK开发包&#xff0c;解压到指定目录。检查系统环境变量是否配置正确&#xff0c;确保编译工具路径已加入PATH。 工程结构初始化 使用MTK提…...

Bloaty二进制大小分析器:10个常见问题解决技巧

Bloaty二进制大小分析器&#xff1a;10个常见问题解决技巧 【免费下载链接】bloaty Bloaty: a size profiler for binaries 项目地址: https://gitcode.com/gh_mirrors/bl/bloaty Bloaty是一款强大的二进制大小分析工具&#xff0c;能够帮助开发者深入了解二进制文件的大…...

Thymeleaf项目部署指南:从开发到生产环境的完整流程

Thymeleaf项目部署指南&#xff1a;从开发到生产环境的完整流程 【免费下载链接】thymeleaf Thymeleaf is a modern server-side Java template engine for both web and standalone environments. 项目地址: https://gitcode.com/gh_mirrors/th/thymeleaf Thymeleaf是一…...

天华新能冲刺港股:年营收75亿净利降56% 宁德时代是二股东 裴振华夫妻套现26亿

雷递网 雷建平 4月3日苏州天华新能源科技股份有限公司&#xff08;简称&#xff1a;“天华新能”&#xff09;日前递交招股书&#xff0c;准备在港交所上市。天华新能2014年在深交所上市&#xff0c;截至今日午盘&#xff0c;天华新能股价为58.6元&#xff0c;市值为487亿元。一…...

MySQL 主从延迟全链路根因诊断与破局法则

MySQL 主从延迟全链路根因诊断与破局法则 在复杂的微服务架构和高并发场景中&#xff0c;数据库的读写分离是标配。然而&#xff0c;伴随而来的“主从延迟”&#xff08;Replication Lag&#xff09;往往是引发线上数据一致性问题的幽灵。很多时候&#xff0c;前端反馈“刚写入…...

嵌入式开发中PC与嵌入式思维的融合实践

1. 嵌入式开发中的PC思维与嵌入式思维融合作为一名从PC端开发转向嵌入式领域的工程师&#xff0c;我深刻体会到两种思维方式的差异与互补。PC编程注重抽象层次和开发效率&#xff0c;而嵌入式编程则必须关注硬件特性和实时性。真正的高手往往能将二者有机结合。在嵌入式领域&am…...

基于SpringBoot + Vue的莱元元电商数据分析系统(双端 + 数据可视化大屏)

文章目录前言一、详细操作演示视频二、具体实现截图三、技术栈1.前端-Vue.js2.后端-SpringBoot3.数据库-MySQL4.系统架构-B/S四、系统测试1.系统测试概述2.系统功能测试3.系统测试结论五、项目代码参考六、数据库代码参考七、项目论文示例结语前言 &#x1f49b;博主介绍&#…...