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

MyBatis 动态 SQL、MyBatis 标签、MyBatis关联查询

MyBatis 动态 SQL、MyBatis 标签、MyBatis关联查询

  • 1、MyBatis动态 sql 的特性
  • 2、MyBatis 标签
    • 2.1、if 标签:条件判断
    • 2.2、where+if 标签
    • 2.3、set 标签
    • 2.4、choose(when,otherwise) 语句
    • 2.5、trim
    • 2.6、MyBatis foreach 标签
  • 3、整合案例
    • 3.1、XML
    • 3.2、测试类
  • 4、sql 标签
  • 5、include 标签
  • 6、 如何引用其他 XML 中的 SQL 片段
  • 7、MyBatis 关联查询
    • 7.1、MyBatis一对多关联查询
    • 7.2、MyBatis多对一关联查询
    • 7.3、MyBatis多对多关联查询

收录的原文地址链接
收录的原文地址链接
收录的原文地址链接

动态 SQL 是 MyBatis 的强大特性之一。在 JDBC 或其它类似的框架中,开发人员通常需要手动拼接 SQL 语句。根据不同的条件拼接 SQL 语句是一件极其痛苦的工作。例如,拼接时要确保添加了必要的空格,还要注意去掉列表最后一个列名的逗号。而动态 SQL 恰好解决了这一问题,可以根据场景动态的构建查询。

动态SQL(code that is executed dynamically),它一般是根据用户输入或外部条件动态组合的SQL语句块。动态SQL能灵活的发挥SQL强大的功能、方便的解决一些其它方法难以解决的问题。相信使用过动态SQL的人都能体会到它带来的便利,然而动态SQL有时候在执行性能 (效率)上面不如静态SQL,而且使用不恰当,往往会在安全方面存在隐患 (SQL 注入式攻击)。

1、MyBatis动态 sql 的特性

(1)Mybatis 动态 sql 是做什么的?
Mybatis 动态 sql 可以让我们在 Xml 映射文件内,以标签的形式编写动态 sql,完成逻辑判断和动态拼接 sql 的功能。

(2)Mybatis 的动态 sql 标签有哪些?

元素作用备注
if判断语句单条件分支判断
choose(when、otherwise)相当于 Java 中的 switch case 语句多条件分支判断
trim、where辅助元素用于处理一些 SQL 拼装问题
foreach循环语句在 in 语句等列举条件中常用
bind辅助元素拼接参数

(3)动态 sql 的执行原理?
原理为:使用 OGNL 从 sql 参数对象中计算表达式的值,根据表达式的值动态拼接 sql,以此来完成动态 sql 的功能。

2、MyBatis 标签

2.1、if 标签:条件判断

MyBatis if 类似于 Java 中的 if 语句,是 MyBatis 中最常用的判断语句。使用 if 标签可以节省许多拼接 SQL 的工作,把精力集中在 XML 的维护上。
(1)不使用动态sql:

<select id="selectUserByUsernameAndSex"resultType="user" parameterType="com.ys.po.User"><!-- 这里和普通的sql 查询语句差不多,对于只有一个参数,后面的 #{id}表示占位符,里面不一定要写id,写啥都可以,但是不要空着,如果有多个参数则必须写pojo类里面的属性 -->select * from user where username=#{username} and sex=#{sex}
</select>

if 语句使用方法简单,常常与 test 属性联合使用。语法如下:

<if test="判断条件">    SQL语句</if>

(2)使用动态sql:
上面的查询语句,我们可以发现,如果 #{username} 为空,那么查询结果也是空,如何解决这个问题呢?使用 if 来判断,可多个 if 语句同时使用。

以下语句表示为可以按照网站名称(name)或者网址(url)进行模糊查询。如果您不输入名称或网址,则返回所有的网站记录。但是,如果你传递了任意一个参数,它就会返回与给定参数相匹配的记录。

<select id="selectAllWebsite" resultMap="myResult">  select id,name,url from website where 1=1    <if test="name != null">        AND name like #{name}   </if>    <if test="url!= null">        AND url like #{url}    </if>
</select>

2.2、where+if 标签

where、if 同时使用可以进行查询、模糊查询。
PS:注意,<if>失败后,<where> 关键字只会去掉库表字段赋值前面的 and,不会去掉语句后面的 and 关键字,即注意,<where> 只会去掉<if> 语句中的最开始的 and 关键字。所以下面的形式是不可取的:

<select id="findQuery" resultType="Student"><include refid="selectvp"/><where><if test="sacc != null">sacc like concat('%' #{sacc} '%')</if><if test="sname != null">AND sname like concat('%' #{sname} '%')</if><if test="sex != null">AND sex=#{sex}</if><if test="phone != null">AND phone=#{phone}</if></where>
</select>

这个 “where” 标签会知道如果它包含的标签中有返回值的话,它就插入一个 ‘where’ 。此外,如果标签返回的内容是以 AND 或 OR 开头的,则它会剔除掉。

2.3、set 标签

set 可以用来修改:

<update id="upd">update student<set><if test="sname != null">sname=#{sname},</if><if test="spwd != null">spwd=#{spwd},</if><if test="sex != null">sex=#{sex},</if><if test="phone != null">phone=#{phone}</if>sid=#{sid}</set>where sid=#{sid}
</update>

2.4、choose(when,otherwise) 语句

有时候,我们不想用到所有的查询条件,只想选择其中的一个,查询条件有一个满足即可,使用 choose 标签可以解决此类问题,类似于 Java 的 switch 语句:

<select id="selectUserByChoose" resultType="com.ys.po.User" parameterType="com.ys.po.User">select * from user<where><choose><when test="id !='' and id != null">id=#{id}</when><when test="username !='' and username != null">and username=#{username}</when><otherwise>and sex=#{sex}</otherwise></choose></where></select>

也就是说,这里我们有三个条件,id、username、sex,只能选择一个作为查询条件:

  • 如果 id 不为空,那么查询语句为:select * from user where id=?
  • 如果 id 为空,那么看username 是否为空,如果不为空,那么语句为 select * from user where username=?;
  • 如果 username 为空,那么查询语句为 select * from user where sex=?

2.5、trim

trim 标记是一个格式化的标记,可以完成 set 者是 where 标记的功能。
(1)用 trim 改写上面第二点的 if+where 语句:

<select id="selectUserByUsernameAndSex" resultType="user" parameterType="com.ys.po.User">select * from user<!-- <where><if test="username != null">username=#{username}</if><if test="username != null">and sex=#{sex}</if></where>  --><trim prefix="where" prefixOverrides="and | or"><if test="username != null">and username=#{username}</if><if test="sex != null">and sex=#{sex}</if></trim>
</select>
  • prefix:前缀;
  • prefixoverride:去掉第一个 and 或者 or。

(2)用 trim 改写上面第三点的 if+set 语句:

<!-- 根据 id 更新 user 表的数据 -->
<update id="updateUserById" parameterType="com.ys.po.User">update user u<!-- <set><if test="username != null and username != ''">u.username = #{username},</if><if test="sex != null and sex != ''">u.sex = #{sex}</if></set> --><trim prefix="set" suffixOverrides=","><if test="username != null and username != ''">u.username = #{username},</if><if test="sex != null and sex != ''">u.sex = #{sex},</if></trim>where id=#{id}
</update>
  • suffix:后缀;
  • suffixoverride:去掉最后一个逗号(也可以是其他的标记,就像是上面前缀中的 and 一样)。

(3)trim+if 同时使用可以添加:

<insert id="add">insert  into student<trim prefix="(" suffix=")" suffixOverrides=","><if test="sname != null">sname,</if><if test="spwd != null">spwd,</if><if test="sex != null">sex,</if><if test="phone != null">phone,</if></trim><trim prefix="values (" suffix=")"  suffixOverrides=","><if test="sname != null">#{sname},</if><if test="spwd != null">#{spwd},</if><if test="sex != null">#{sex},</if><if test="phone != null">#{phone}</if></trim></insert>

2.6、MyBatis foreach 标签

foreach 是用来对集合的遍历,这个和 Java 中的功能很类似。通常处理 SQL 中的 in 语句。

foreach 元素的功能非常强大,它允许你指定一个集合,声明可以在元素体内使用的集合项(item)和索引(index)变量。它也允许你指定开头与结尾的字符串以及集合项迭代之间的分隔符。这个元素也不会错误地添加多余的分隔符。

你可以将任何可迭代对象(如 List、Set 等)、Map 对象或者数组对象作为集合参数传递给 foreach。当使用可迭代对象或者数组时,index 是当前迭代的序号,item 的值是本次迭代获取到的元素。当使用 Map 对象(或者 Map.Entry 对象的集合)时,index 是键,item 是值。

//批量查询
<select id="findAll" resultType="Student" parameterType="Integer"><include refid="selectvp"/> WHERE sid in<foreach item="ids" collection="array"  open="(" separator="," close=")">#{ids}</foreach>
</select>
//批量删除
<delete id="del"  parameterType="Integer">delete  from  student  where  sid in<foreach item="ids" collection="array"  open="(" separator="," close=")">#{ids}</foreach>
</delete>

3、整合案例

3.1、XML

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="com.yzx.mapper.StuMapper"><sql id="selectvp">select  *  from  student</sql><select id="find" resultType="Student"><include refid="selectvp"/></select><select id="findbyid"  resultType="student"><include refid="selectvp"/>WHERE 1=1<if test="sid != null">AND sid like #{sid}</if></select><select id="findQuery" resultType="Student"><include refid="selectvp"/><where><if test="sacc != null">sacc like concat('%' #{sacc} '%')</if><if test="sname != null">AND sname like concat('%' #{sname} '%')</if><if test="sex != null">AND sex=#{sex}</if><if test="phone != null">AND phone=#{phone}</if></where></select><update id="upd">update student<set><if test="sname != null">sname=#{sname},</if><if test="spwd != null">spwd=#{spwd},</if><if test="sex != null">sex=#{sex},</if><if test="phone != null">phone=#{phone}</if>sid=#{sid}</set>where sid=#{sid}</update><insert id="add">insert  into student<trim prefix="(" suffix=")" suffixOverrides=","><if test="sname != null">sname,</if><if test="spwd != null">spwd,</if><if test="sex != null">sex,</if><if test="phone != null">phone,</if></trim><trim prefix="values (" suffix=")"  suffixOverrides=","><if test="sname != null">#{sname},</if><if test="spwd != null">#{spwd},</if><if test="sex != null">#{sex},</if><if test="phone != null">#{phone}</if></trim></insert><select id="findAll" resultType="Student" parameterType="Integer"><include refid="selectvp"/> WHERE sid in<foreach item="ids" collection="array"  open="(" separator="," close=")">#{ids}</foreach></select><delete id="del"  parameterType="Integer">delete  from  student  where  sid in<foreach item="ids" collection="array"  open="(" separator="," close=")">#{ids}</foreach></delete></mapper>

3.2、测试类

测试类:

package com.yzx.test;import com.yzx.entity.Student;
import com.yzx.mapper.StuMapper;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;import java.io.IOException;
import java.io.InputStream;
import java.util.List;public class StuTest {SqlSession sqlSession=null;InputStream is=null;@Beforepublic   void  before() throws IOException {//1.读取核心配置文件is= Resources.getResourceAsStream("sqlMapperConfig.xml");//2.拿到工厂构建类SqlSessionFactoryBuilder sqlSessionFactoryBuilder=new SqlSessionFactoryBuilder();//3.拿到具体工厂SqlSessionFactory build=sqlSessionFactoryBuilder.build(is);//4.拿到sessionsqlSession = build.openSession();}@Afterpublic  void  after(){//7,提交事务sqlSession.commit();//8.关闭资源sqlSession.close();if(is!=null){try {is.close();} catch (IOException e) {e.printStackTrace();}};}//查询所有@Testpublic  void  find(){//5.获取具体的mapper接口StuMapper mapper=sqlSession.getMapper(StuMapper.class);//6.调用执行List<Student> list=mapper.find();list.forEach(a-> System.out.println(a));}//查询单个@Testpublic  void  findbyid(){StuMapper mapper=sqlSession.getMapper(StuMapper.class);List<Student> list=mapper.findbyid(2);list.forEach(a-> System.out.println(a));}//模糊查询@Testpublic  void  findQuery(){StuMapper mapper=sqlSession.getMapper(StuMapper.class);Student  stu=new Student();stu.setSname("小");stu.setSex("男");List<Student> list=mapper.findQuery(stu);list.forEach(a-> System.out.println(a));}//修改@Testpublic  void  upd(){StuMapper mapper=sqlSession.getMapper(StuMapper.class);Student  stu=new Student();stu.setSid(3);stu.setSname("小若");stu.setSex("人妖");int i=mapper.upd(stu);System.out.println("修改了"+i+"条数据"+"  "+stu.toString());}//添加@Testpublic  void  add(){StuMapper mapper=sqlSession.getMapper(StuMapper.class);Student  stu=new Student();stu.setSname("小贺");stu.setSex("男");stu.setPhone("99999999");int i=mapper.add(stu);System.out.println("添加了"+i+"条数据"+"  "+stu.toString());}//批量操作@Testpublic  void  findAll(){StuMapper mapper=sqlSession.getMapper(StuMapper.class);Integer[] i={1,2,3,4};List<Student> list=mapper.findAll(i);list.forEach(a-> System.out.println(a));}//批量操作//批量删除@Testpublic  void  del(){StuMapper mapper=sqlSession.getMapper(StuMapper.class);Integer[] i={1,2,3,4};int i1=mapper.del(i);System.out.println("删除了"+i1+"条数据");}
}

4、sql 标签

在实际开发中会遇到许多相同的 SQL,比如根据某个条件筛选,这个筛选很多地方都能用到,我们可以将其抽取出来成为一个公用的部分,这样修改也方便,一旦出现了错误,只需要改这一处便能处处生效了,此时就用到了 <sql> 这个标签了。

当多种类型的查询语句的查询字段或者查询条件相同时,可以将其定义为常量,方便调用。为求 <select> 结构清晰也可将 sql 语句分解。

<sql id="selectvp">select  *  from  student
</sql>

5、include 标签

这个标签和 <sql> 是天仙配,是共生的,include 用于引用 sql 标签定义的常量。比如引用上面 sql 标签定义的常量。

refid 这个属性就是指定 <sql> 标签中的 id 值(唯一标识):

<select id="findbyid"  resultType="student"><include refid="selectvp"/>WHERE 1=1<if test="sid != null">AND sid like #{sid}</if>
</select>

6、 如何引用其他 XML 中的 SQL 片段

比如你在 com.xxx.dao.xxMapper 这个 Mapper 的 XML 中定义了一个 SQL 片段如下:

<sql id="Base_Column_List"> ID,MAJOR,BIRTHDAY,AGE,NAME,HOBBY</sql>

此时我在 com.xxx.dao.Patinet 这个 Mapper 中的 XML 文件中需要引用,如下:

<include refid="com.xxx.dao.xxMapper.Base_Column_List"></include>

7、MyBatis 关联查询

7.1、MyBatis一对多关联查询

<!--一对多-->
<resultMap id="myStudent1" type="student1"><id property="sid" column="sid"/><result property="sname" column="sname"/><result property="sex" column="sex"/><result property="sage" column="sage"/><collection property="list" ofType="teacher"><id property="tid" column="tid"/><result property="tname" column="tname"/><result property="tage" column="tage"/></collection>
</resultMap><!--一对多-->
<select id="find1" resultMap="myStudent1">select  *  from  student1  s  left  join  teacher  t  on s.sid=t.sid
</select>

7.2、MyBatis多对一关联查询

<!--多对一-->
<resultMap id="myTeacher" type="teacher"><id property="tid" column="tid"/><result property="tname" column="tname"/><result property="tage" column="tage"/><association property="student1" javaType="Student1"><id property="sid" column="sid"/><result property="sname" column="sname"/><result property="sex" column="sex"/><result property="sage" column="sage"/></association>
</resultMap><!--多对一-->
<select id="find2" resultMap="myTeacher">
select  *  from  teacher  t right join student1 s on  t.sid=s.sid
</select>

7.3、MyBatis多对多关联查询

<!--多对多 以谁为主表查询的时候,主表约等于1的一方,另一方相当于多的一方-->
<select id="find3" resultMap="myStudent1">select  *  from  student1 s  left join relevance r on  s.sid=r.sid  left join teacher t on  r.tid=t.tid
</select>

相关文章:

MyBatis 动态 SQL、MyBatis 标签、MyBatis关联查询

MyBatis 动态 SQL、MyBatis 标签、MyBatis关联查询 1、MyBatis动态 sql 的特性2、MyBatis 标签2.1、if 标签&#xff1a;条件判断2.2、whereif 标签2.3、set 标签2.4、choose(when,otherwise) 语句2.5、trim2.6、MyBatis foreach 标签 3、整合案例3.1、XML3.2、测试类 4、sql 标…...

在Vue中使用Immutable.js

在Vue3中使用Immutable.js 以下是如何在Vue.js中使用Immutable.js的步骤&#xff1a; 首先&#xff0c;需要安装immutable.js。你可以通过npm或yarn来安装&#xff1a; npm install immutable或者 yarn add immutable在你的Vue组件中导入Immutable&#xff1a; import { Ma…...

基于Yolov8的工业端面小目标计数检测(1)

1.端面小目标计数数据集介绍 工业端面小目标计数类别:一类,类别名object 数据集大小:训练集864张,验证集98张 缺陷特点:小目标计数,检测难度大,如下图所示; 1.1 小目标定义 1)以物体检测领域的通用数据集COCO物体定义为例,小目标是指小于3232个像素点(中物体是指…...

1.什么是jwt?jwt的作用是什么?2.jwt的三个部分是什么?三者之间的关系如何?3.JWT运行的流程是什么

1. **什么是JWT&#xff1f;JWT的作用是什么&#xff1f;** JWT&#xff08;JSON Web Token&#xff09;是一种用于在不同系统或组件之间传输信息的紧凑且安全的标准。它的作用主要有两个方面&#xff1a; - **身份验证&#xff08;Authentication&#xff09;**&#xf…...

十三、MySql的视图

文章目录 一、前言二、定义三、为什么使用视图四、基本使用&#xff08;—&#xff09;创建视图&#xff08;二&#xff09;案例1.修改了视图&#xff0c;对基表数据有影响2.修改了基表&#xff0c;对视图有影响3.删除视图 五、视图规则和限制 一、前言 通过视图&#xff0c;可…...

MFC扩展库BCGControlBar Pro v33.6亮点 - 流程图、Ribbon Bar功能升级

BCGControlBar库拥有500多个经过全面设计、测试和充分记录的MFC扩展类。 我们的组件可以轻松地集成到您的应用程序中&#xff0c;并为您节省数百个开发和调试时间。 BCGControlBar专业版 v33.6已正式发布了&#xff0c;此版本包含了对图表组件的改进、带隐藏标签的单类功能区栏…...

前端 JS 经典:文件流下载

重点&#xff1a;调用接口时&#xff0c;一定要配置 responseType 的值为 blob&#xff0c;不然获取的文件流&#xff0c;不会转义成 blob 类型的文件。 1. 接口返回文件流 // BLOB (binary large object)----二进制大对象&#xff0c;是一个可以存储二进制文件的容器 // 下载…...

SSL免费证书会报安全提示吗?

安全性是互联网世界中至关重要的一环&#xff0c;其中一个关键组成部分就是SSL证书&#xff0c;它们用于加密在用户浏览器和服务器之间传输的数据&#xff0c;以确保数据的保密性和完整性。然而&#xff0c;有关SSL证书的一个常见问题是&#xff1a;免费SSL证书是否会触发安全警…...

为什么要选择Spring cloud Sentinel

为什么要选择Spring cloud Sentinel &#x1f34e;对比Hystrix&#x1f342;雪崩问题及解决方案&#x1f342;雪崩问题&#x1f342;.超时处理&#x1f342;仓壁模式&#x1f342;断路器&#x1f342;限流&#x1f342;总结 &#x1f34e;对比Hystrix 在SpringCloud当中支持多…...

第八天:gec6818arm开发板和Ubuntu中安装并且编译移植mysql驱动连接QT执行程序

一、Ubuntu18.04中安装并且编译移植mysql驱动程序连接qt执行程序 1 、安装Mysql sudo apt-get install mysql-serverapt-get isntall mysql-clientsudo apt-get install libmysqlclient-d2、查看是否安装成功&#xff0c;即查看MySQL版本 mysql --version 3、MySQL启动…...

使用JavaScript实现图片的自动轮播

介绍 在网站开发中&#xff0c;经常会遇到需要展示多张图片并自动切换的需求&#xff0c;这就需要使用JavaScript来实现图片的自动轮播功能。本文将通过一个简单的例子&#xff0c;演示如何用JavaScript实现图片的自动轮播。 实现步骤&#xff1a; HTML结构&#xff1a; 首先…...

React 如何拿时间戳计算得到开始和结束时间戳

获取需要的时间戳(开始 and 结束时间戳) 调用如下方法就行&#xff1a; function getWantTimestamp(props) {//当前时间const nowDate parseInt((new Date().getTime() / 1000).toString()); //当前时间switch (props) {// 当前时间时间戳case "nowData": {return n…...

leetcode114 二叉树展开为链表

题目 给你二叉树的根结点 root &#xff0c;请你将它展开为一个单链表&#xff1a; 展开后的单链表应该同样使用 TreeNode &#xff0c;其中 right 子指针指向链表中下一个结点&#xff0c;而左子指针始终为 null 。 展开后的单链表应该与二叉树 先序遍历 顺序相同。 示例 输…...

Linux系统上使用SQLite

1. 安装SQLite 在Linux上安装SQLite非常简单。可以使用包管理器&#xff08;如apt、yum&#xff09;直接从官方软件源安装SQLite。例如&#xff0c;在Ubuntu上使用以下命令安装SQLite&#xff1a; sudo apt-get install sqlite32. 打开或创建数据库 要打开或创建一个SQLite数…...

实现一个超级简单的string类(基于c++)

简单的string仅仅需要构造函数&#xff0c;拷贝构造,移动构造和移动赋值&#xff0c;operator&#xff0c;析构函数等。如下&#xff1a; #include<iostream> #include<assert.h> using namespace std; namespace qyy {class string{public:friend ostream& …...

uniapp存值和取值,获取登录凭证 code方法

Uniapp 的存值和取值 Uniapp 的存值和取值方法可以使用Vue.js的数据绑定方式&#xff0c;也可以使用uni.setStorageSync() 和 uni.getStorageSync() 方法。 使用Vue.js的数据绑定方式&#xff1a; 在Vue组件中定义一个data属性&#xff0c;然后将需要存储的值赋给该属性。例…...

【SpringCloud微服务全家桶学习笔记-服务调用Ribbon/openFeign】

SpringCloud微服务全家桶学习笔记 内容&#xff1a;SpringCloud SpringCloud alibaba 技术栈&#xff1a;Java8mavengit&#xff0c;githubNginxRabbitMQSpringBoot2.0 仓库&#xff1a;链接 服务调用Ribbon 是什么&#xff1f; Ribbon是Netflix发布的开源项目&#xff…...

Qt使用I.MX6U开发板上的按键(原理:将电脑键盘方向键↓在Qt中的枚举值与开发板中按键定义的枚举值一致,这样电脑端测试效果就与开发板的一致)

在上篇介绍了Qt点亮I.MX6U开发板的一个LED&#xff0c;对于Qt控制I.MX6U开发板的一个蜂鸣器原理也是一样的&#xff0c;就不做详细介绍&#xff0c;具体可参考Qt控制I.MX6U开发板的一个蜂鸣器&#xff0c;本篇介绍Qt使用I.MX6U开发板上的按键的相关内容。 文章目录 1. 开发板硬…...

C++ RAII在HotSpot VM中的重要应用

RAII&#xff08;Resource Acquisition Is Initialization&#xff09;&#xff0c;也称为“资源获取就是初始化”&#xff0c;是C语言的一种管理资源、避免泄漏的惯用法。C标准保证任何情况下&#xff0c;已构造的对象最终会销毁&#xff0c;即它的析构函数最终会被调用。简单…...

python随手小练

题目&#xff1a; 使用python做一个简单的英雄联盟商城登录界面 具体操作&#xff1a; print("英雄联盟商城登录界面") print("~ * "*15 "~") #找其规律 a "1、用户登录" b "2、新用户注册" c "3、退出系统&quo…...

Windows下Git 2.43.2安装全攻略:从下载到配置的避坑指南

Windows下Git 2.43.2安装全攻略&#xff1a;从下载到配置的避坑指南 对于Windows开发者而言&#xff0c;Git已经成为版本控制的标准工具。但许多新手在初次安装时&#xff0c;面对密密麻麻的选项和术语常常感到困惑。本文将带你一步步完成Git 2.43.2的安装过程&#xff0c;不仅…...

力扣第97题:多数元素

第一部分:问题描述 给定一个大小为 n 的数组 nums ,返回其中的多数元素。多数元素是指在数组中出现次数 大于 ⌊ n/2 ⌋ 的元素。 你可以假设数组是非空的,并且给定的数组总是存在多数元素。 示例 1: 输入:nums = [3,2,3] 输出:3 示例 2: 输入:nums = [2,2,1,1,1…...

用快马AI快速原型你的技能组合:一键生成个人技能展示页

今天想和大家分享一个快速验证技能组合的小技巧——用InsCode(快马)平台一键生成个人技能展示页。作为开发者&#xff0c;我们经常需要向团队或客户展示自己的技术栈&#xff0c;但手动写前端页面太耗时。最近发现用AI生成原型特别高效&#xff0c;整个过程不到10分钟就能获得可…...

2023年数字图像处理实战:从噪声滤除到图像恢复的八大核心考题解析

1. 椒噪声滤除&#xff1a;自适应中值滤波实战 遇到图像布满黑白噪点&#xff08;椒盐噪声&#xff09;时&#xff0c;传统中值滤波直接暴力替换像素可能误伤细节。去年帮学弟调试车牌识别系统时就遇到过这种情况——滤波后车牌数字"7"直接变成了"1"。后来…...

告别VMware窗口切换!用Termius SSH直连CentOS 7虚拟机的保姆级教程

告别VMware窗口切换&#xff01;用Termius SSH直连CentOS 7虚拟机的保姆级教程 每次在宿主机和虚拟机之间来回切换窗口&#xff0c;是不是让你感到效率低下&#xff1f;尤其当需要同时操作多个虚拟机时&#xff0c;频繁的窗口切换不仅浪费时间&#xff0c;还容易打断工作流。本…...

【新手必看】鼎利测试软件Pilot Pioneer-② 工具栏与菜单栏功能详解

1. Pilot Pioneer工具栏全解析 刚接触鼎利测试软件Pilot Pioneer时&#xff0c;最让我头疼的就是密密麻麻的工具栏图标。但用久了才发现&#xff0c;这些看似复杂的按钮其实是提升效率的"快捷键"。先说说最上方的自定义快速访问工具栏&#xff0c;这个区域就像手机桌…...

Word论文写作福音:3分钟搞定APA第7版参考文献格式配置

Word论文写作福音&#xff1a;3分钟搞定APA第7版参考文献格式配置 【免费下载链接】APA-7th-Edition Microsoft Word XSD for generating APA 7th edition references 项目地址: https://gitcode.com/gh_mirrors/ap/APA-7th-Edition 还在为论文参考文献格式发愁吗&#…...

医疗AI辅助诊断渲染延迟>180ms?立即执行这4项C++17 constexpr预计算+SIMD向量化改造(附VS2022 / CLion双环境调试checklist)

第一章&#xff1a;医疗AI辅助诊断渲染延迟的临床影响与性能基线定义在放射科、病理科及急诊超声等实时影像决策场景中&#xff0c;AI辅助诊断系统若出现毫秒级渲染延迟&#xff0c;可能直接干扰医生对动态血流、心室壁运动或微小结节增强特征的连续性判读。临床研究表明&#…...

Win11Debloat极速优化指南:让Windows系统重获新生的深度净化方案

Win11Debloat极速优化指南&#xff1a;让Windows系统重获新生的深度净化方案 【免费下载链接】Win11Debloat A simple, lightweight PowerShell script that allows you to remove pre-installed apps, disable telemetry, as well as perform various other changes to declut…...

如何用Fuel构建类型安全的GraphQL客户端:终极完整指南

如何用Fuel构建类型安全的GraphQL客户端&#xff1a;终极完整指南 【免费下载链接】fuel The easiest HTTP networking library for Kotlin/Android 项目地址: https://gitcode.com/gh_mirrors/fu/fuel Fuel是Kotlin/Android平台上最简单易用的HTTP网络库&#xff0c;它…...