MyBatis从入门到“入土“

 💕喜欢的朋友可以关注一下,下次更新不迷路!💕(●'◡'●)

目录

一、Mybatis为何物?👌

二、快速入门🤣

 1、新建项目😊

2、数据库建表😊

3、导入依赖的jar包😊

4、根据表建pojo类😊

5、编写mapper映射文件(编写sql)😊

 6、编写全局配置文件(主要是配置数据源信息)😊

7、测试😊

三、快速入土😢

代理开发😂

1、定义与SQL映射文件同名的Mapper接口,并且将Mapper接口和SQL映射文件放置在同一目录下。

2、设置SQL映射文件的namespace属性为Mapper接口全限定名。

3、在Mapper接口中定义方法,方法名就是SQL映射文件中sql语句的id,并保持参数类型和返回值类型一致。

4、通过SqlSession的getMapper方法获取Mapper接口的代理对象,并调用对应方法。

 Mybatis核心配置--mybatis-config.xml😂

1、可以连接多个数据库

 2、配置标签

案例😂

1、 建表

2、实体类

3、测试类

4、mybatisx插件

根据方法自动生成mapper映射文件

 5、查询(查询所有)

6、查看详情(根据id查询一个)

7、条件查询

 根据参数接收(无参/一个参数/两个参数/)

散装参数(模糊匹配)

对象参数

map参数

 动态条件查询(用户输入条件时,是否所有条件都会填写。不是,哥们🤣👌)

 使用if,choose,when设定条件

 8、添加

 主键返回

 9、修改

修改全部字段

 修改动态字段

10、删除

单个删除

批量删除

 注解开发😍


 

一、Mybatis为何物?👌

🤦‍♂️恶臭的描述: MyBatis 是一个优秀的持久层框架,它对JDBC的操作数据库的过程进行封装,让开发者只需要关注 SQL 本身,而不需要花费精力去处理例如注册驱动、创建connection、创建statement、手动设置参数、结果集检索等JDBC繁琐的过程代码。

❤️舒服的描述:

不需要手动编写 JDBC 代码来执行 SQL 语句,也不需要处理数据库连接的创建和关闭。

所有的数据库操作都被抽象成了简单的 Mapper 方法调用。 (伟大无需多言!)

Mybatis中文官网

二、快速入门🤣

 前言:

完整结构图

只需要通过如下几个步骤,即可用mybatis快速进行持久层的开发

  1. 编写全局配置文件
  2. 编写mapper映射文件
  3. 加载全局配置文件,生成SqlSessionFactory
  4. 创建SqlSession,调用mapper映射文件中的SQL语句来执行CRUD操作

🤣话不多说,直接Mybatis启动!🤣

 1、新建项目😊

java8

2、数据库建表😊

3、导入依赖的jar包😊

<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/maven-v4_0_0.xsd"><modelVersion>4.0.0</modelVersion><groupId>org.itqingshui</groupId><artifactId>mybatis-test1</artifactId><version>1.0-SNAPSHOT</version><name>Archetype - mybatis-test1</name><url>http://maven.apache.org</url><dependencies><dependency><groupId>org.mybatis</groupId><artifactId>mybatis</artifactId><version>3.5.6</version></dependency><dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId><version>8.0.21</version></dependency><dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId><version>1.18.30</version></dependency></dependencies><build><plugins><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><version>3.8.1</version><configuration><source>1.8</source> <!-- 替换为你的JDK版本 --><target>1.8</target> <!-- 替换为你的JDK版本 --></configuration></plugin></plugins></build></project>

4、根据表建pojo类😊

package pojo;import lombok.*;@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@ToString
public class Student{private Integer id;private String name;private Integer score;private Integer age;private Integer gender;
}
@Getter
@Setter:省略set,get方法。
@NoArgsConstructor:建立一个无参构造器。
@AllArgsConstructor:建立一个全参构造器。
@ToString:建立一个tostring方法。

5、编写mapper映射文件(编写sql)😊

<?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="pojo.StudentMapper"><select id="findAll" resultType="pojo.Student">select * from student</select><insert id="insert" parameterType="pojo.Student">insert into student(name,gender,age,score) values(#{name},#{gender},#{age},#{score})</insert><delete id="delete" parameterType="int">delete from student where id=#{id}</delete><update id="update" parameterType="pojo.Student">update student set name=#{name},gender=#{gender},age=#{age},score=#{score} where id=#{id}</update></mapper>

 6、编写全局配置文件(主要是配置数据源信息)😊

resources包下 

<?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><environments default="development"><environment id="development"><transactionManager type="JDBC"/><dataSource type="POOLED"><property name="driver" value="com.mysql.cj.jdbc.Driver"/><property name="url" value="jdbc:mysql://localhost:3306/ssm?useSSL=false&amp;serverTimezone=UTC"/><property name="username" value="lovertx"/><property name="password" value="1234567"/></dataSource></environment></environments><mappers><!-- 加载编写的SQL语句 --><mapper resource="StudentMapper.xml"/></mappers>
</configuration>

7、测试😊

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 pojo.Student;import java.io.IOException;
import java.io.InputStream;
import java.util.List;public class MybatisDemo {public static void main(String[] args) throws IOException, ClassNotFoundException {String resource = "mybatis-config.xml";InputStream inputStream = Resources.getResourceAsStream(resource);SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);SqlSession sqlSession = sqlSessionFactory.openSession();List<Student> student = sqlSession.selectList("pojo.StudentMapper.findAll");for (Student s : student){System.out.println(s);}sqlSession.close();}
}

三、快速入土😢

代理开发😂

对于

  List<Student> student = sqlSession.selectList("pojo.StudentMapper.findAll");

目的:

解决原生方式中的硬编码。

简化后期执行SQL

 

1、定义与SQL映射文件同名的Mapper接口,并且将Mapper接口和SQL映射文件放置在同一目录下。

在resources包下创建mapper包并放入StudentMapper.xml

2、设置SQL映射文件的namespace属性为Mapper接口全限定名。

<mapper namespace="pojo.StudentMapper">

改为 

<mapper namespace="mapper.StudentMapper">

3、在Mapper接口中定义方法,方法名就是SQL映射文件中sql语句的id,并保持参数类型和返回值类型一致。

StudentMapper中 

package mapper;import pojo.Student;import java.util.List;public interface StudentMapper {List<Student>  findAll();
}

4、通过SqlSession的getMapper方法获取Mapper接口的代理对象,并调用对应方法。

StudentMapper userMapper = sqlSession.getMapper(StudentMapper.class);
userMapper.findAll().forEach(System.out::println);

 Mybatis核心配置--mybatis-config.xml😂

1、可以连接多个数据库

可以配置多个environment,通过default属性切换不同的environment 

<?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><environments default="development"><environment id="development"><transactionManager type="JDBC"/><dataSource type="POOLED"><property name="driver" value="com.mysql.cj.jdbc.Driver"/><property name="url" value="jdbc:mysql://localhost:3306/ssm?useSSL=false&amp;serverTimezone=UTC"/><property name="username" value="lovertx"/><property name="password" value="1234567"/></dataSource></environment></environments><environments default="development"><environment id="development"><transactionManager type="JDBC"/><dataSource type="POOLED"><property name="driver" value="com.mysql.cj.jdbc.Driver"/><property name="url" value="jdbc:mysql://localhost:3306/ssm?useSSL=false&amp;serverTimezone=UTC"/><property name="username" value="lovertx"/><property name="password" value="1234567"/></dataSource></environment></environments><mappers><!-- 加载编写的SQL语句 --><mapper resource="mapper/StudentMapper.xml"/></mappers>
</configuration>

 2、配置标签

案例😂

1、 建表

id:主键

brand_name:品牌名称

company_name:企业名称

ordered:排序字段

description:描述信息

status:状态(0:禁用,1启用)

2、实体类

package pojo;import lombok.*;@Setter
@Getter
@NoArgsConstructor
@AllArgsConstructor
@ToString
public class Brand {private Integer id;private String brand_name;private String company_name;private Integer ordered;private String description;private Integer status;
}

3、测试类

4、mybatisx插件

通过点击左边的红色小鸟 

 

可以找到蓝色小鸟

 

 

根据方法自动生成mapper映射文件

1、第一步:在StudentMapper中

package mapper;import pojo.Student;import java.util.List;public interface StudentMapper {List<Student>  findAll();Student findById(int id);
}

2、使用插件自动生成

<select id="findById" resultType="pojo.Student"></select>

3、补充实际操作

<select id="findById" resultType="pojo.Student">select * from student where id=#{id}</select>

 5、查询(查询所有)

1、创建BrandMapper(先写方法,后自动写sql)

 

package mapper;import pojo.Brand;
import java.util.List;public interface BrandMapper {List<Brand> findAll();
}

2、创建BrandMapper.xml

package mapper;import pojo.Brand;
import java.util.List;public interface BrandMapper {List<Brand> findAll();
}

 3、配置映射文件

在mybatis-config.xml添加 <mapper resource="mapper/BrandMapper.xml"/>

<mappers><!-- 加载编写的SQL语句 --><mapper resource="mapper/StudentMapper.xml"/><mapper resource="mapper/BrandMapper.xml"/></mappers>

 4、测试类

import mapper.BrandMapper;
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 java.io.IOException;
import java.io.InputStream;public class MybatisDemo3 {public static void main(String[] args) throws IOException, ClassNotFoundException {String resource = "mybatis-config.xml";InputStream inputStream = Resources.getResourceAsStream(resource);SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);SqlSession sqlSession = sqlSessionFactory.openSession();BrandMapper userMapper = sqlSession.getMapper(BrandMapper.class);userMapper.findAll().forEach(System.out::println);sqlSession.close();}
}

6、查看详情(根据id查询一个)

BrandMapper中写: 

Brand findById(int id);
public interface BrandMapper {List<Brand> findAll();Brand findById(int id);
}

BrandMapper.xml中写:

<select id="findById" resultType="pojo.Brand">select * from tb_brand where id = #{id}</select>

 测试类中写:

public class MybatisDemo {public static void main(String[] args) throws IOException, ClassNotFoundException {String resource = "mybatis-config.xml";InputStream inputStream = Resources.getResourceAsStream(resource);SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);SqlSession sqlSession = sqlSessionFactory.openSession();BrandMapper brandMapper = sqlSession.getMapper(BrandMapper.class);Brand brand = brandMapper.findById(1);System.out.println(brand);sqlSession.close();}
}

7、条件查询

类似于实现这样的功能:

 根据参数接收(无参/一个参数/两个参数/)
散装参数(模糊匹配)

因模糊匹配需要处理参数

接口方法

List<Brand> selectByCondition(@Param("status") int status, @Param("company_name") String company_name, @Param("brand_name") String brand_name);

sql语句

<select id="selectByCondition" resultType="pojo.Brand">select * from tb_brandwhere status = #{status}and brand_name like #{brand_name}and company_name like #{company_name}</select>

测试类 

public class MybatisDemo {public static void main(String[] args) throws IOException {//接收参数int status = 1;String company_name = "华为";String brand_name = "华为";//因模糊匹配,所有处理参数company_name = "%" + company_name + "%";brand_name = "%" + brand_name + "%";String resource = "mybatis-config.xml";InputStream inputStream = Resources.getResourceAsStream(resource);SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);SqlSession sqlSession = sqlSessionFactory.openSession();BrandMapper brandMapper = sqlSession.getMapper(BrandMapper.class);List<Brand> brands = brandMapper.selectByCondition(status, company_name, brand_name);for (Brand brand : brands) {System.out.println(brand);}sqlSession.close();}
}

 

对象参数

对象的属性名称要和参数占位符名称一致


Mapper接口:

List<Brand> selectByCondition(Brand brand);

sql语句:

<select id="selectByCondition" resultType="pojo.Brand">select * from tb_brandwhere status = #{status}and brand_name like #{brand_name}and company_name like #{company_name}</select>

 测试类:

多了个封装对象

public class MybatisDemo {public static void main(String[] args) throws IOException {//接收参数int status = 1;String company_name = "华为";String brand_name = "华为";//因模糊匹配,所有处理参数company_name = "%" + company_name + "%";brand_name = "%" + brand_name + "%";//封装对象Brand brand = new Brand();brand.setStatus(status);brand.setCompany_name(company_name);brand.setBrand_name(brand_name);String resource = "mybatis-config.xml";InputStream inputStream = Resources.getResourceAsStream(resource);SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);SqlSession sqlSession = sqlSessionFactory.openSession();BrandMapper brandMapper = sqlSession.getMapper(BrandMapper.class);//      List<Brand> brands = brandMapper.selectByCondition(status, company_name, brand_name);List<Brand> brands = brandMapper.selectByCondition(brand);for (Brand brand1 : brands) {System.out.println(brand1);}sqlSession.close();}
}

map参数

 Mapper接口:

List<Brand> selectByCondition(Map map);

sql语句:

<select id="selectByCondition" resultType="pojo.Brand">select * from tb_brandwhere status = #{status}and brand_name like #{brand_name}and company_name like #{company_name}</select>

测试类:

public class MybatisDemo {public static void main(String[] args) throws IOException {//接收参数int status = 1;String company_name = "华为";String brand_name = "华为";//因模糊匹配,所有处理参数company_name = "%" + company_name + "%";brand_name = "%" + brand_name + "%";//封装对象
//        Brand brand = new Brand();
//        brand.setStatus(status);
//        brand.setCompany_name(company_name);
//        brand.setBrand_name(brand_name);Map map = new HashMap();map.put("status",status);map.put("company_name",company_name);map.put("brand_name",brand_name);String resource = "mybatis-config.xml";InputStream inputStream = Resources.getResourceAsStream(resource);SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);SqlSession sqlSession = sqlSessionFactory.openSession();BrandMapper brandMapper = sqlSession.getMapper(BrandMapper.class);//      List<Brand> brands = brandMapper.selectByCondition(status, company_name, brand_name);
//      List<Brand> brands = brandMapper.selectByCondition(brand);List<Brand> brands = brandMapper.selectByCondition(map);for (Brand brand1 : brands) {System.out.println(brand1);}sqlSession.close();}
}
 动态条件查询(用户输入条件时,是否所有条件都会填写。不是,哥们🤣👌)

只需要修改sql语句:

<select id="selectByCondition" resultType="pojo.Brand">select * from tb_brandwhere<if test="status != null">status = #{status}</if><if test="brand_name != null and brand_name != ''">and brand_name like #{brand_name}</if><if test="company_name != null and company_name != ''">and company_name like #{company_name}</if></select>

  可是当特殊条件缺少时会出现错误:

 Map map = new HashMap();//map.put("status",status);map.put("company_name",company_name);//map.put("brand_name",brand_name);

 解决:恒等式

将sql语句修改为:

<select id="selectByCondition" resultType="pojo.Brand">select * from tb_brand<where><if test="status != null">and status = #{status}</if><if test="brand_name != null and brand_name != ''">and brand_name like #{brand_name}</if><if test="company_name != null and company_name != ''">and company_name like #{company_name}</if></where></select>
 使用if,choose,when设定条件
<select id="selectByConditionOne" resultType="pojo.Brand">select * from tb_brandwhere<choose><!--相当于switch--><when test="status != null"><!--相当于case-->status = #{status}</when><when test="brand_name != null and brand_name != ''">brand_name like #{brand_name}</when><when test="company_name != null and company_name != ''">company_name like #{company_name}</when><otherwise><!--当用户一个条件都不给-->1=1</otherwise></choose></select>

 8、添加

 接口方法

void add(Brand brand);

sql语句

<insert id="add">insert into tb_brand(brand_name,company_name,ordered,description,status)values(#{brand_name},#{company_name},#{ordered},#{description},#{status})</insert>

 测试类

public class MybatisDemo3 {public static void main(String[] args) throws IOException, ClassNotFoundException {String resource = "mybatis-config.xml";InputStream inputStream = Resources.getResourceAsStream(resource);SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);SqlSession sqlSession = sqlSessionFactory.openSession();BrandMapper userMapper = sqlSession.getMapper(BrandMapper.class);int status = 1;String company_name = "菠萝手机";String brand_name = "菠萝";int ordered = 1;String description = "美国有苹果,中国有菠萝";Brand brand = new Brand();brand.setStatus(status);brand.setCompany_name(company_name);brand.setBrand_name(brand_name);brand.setOrdered(ordered);brand.setDescription(description);userMapper.add(brand);
//事务提交sqlSession.commit();sqlSession.close();}
}
 主键返回

实现可查询主键id的值

 因为事务回滚导致少了id=4

因此查询菠萝的id的值为5


将sql语句改为

<insert id="add" useGeneratedKeys="true" keyProperty="id">insert into tb_brand(brand_name,company_name,ordered,description,status)values(#{brand_name},#{company_name},#{ordered},#{description},#{status})</insert>

即添加

useGeneratedKeys="true" keyProperty="id"

 9、修改

修改全部字段

实现

 Mapper接口

void update(Brand brand);

SQL语句

<update id="update">update tb_brand<set><if test="brand_name != null and brand_name != ''">brand_name = #{brand_name},</if><if test="company_name != null and company_name != ''">company_name = #{company_name},</if><if test="ordered != null">ordered = #{ordered},</if><if test="description != null and description != ''">description =#{description},status = #{status}</if>where id = #{id}</set></update>

测试类

public class UpdateTest {public static void main(String[] args) throws IOException{String resource = "mybatis-config.xml";InputStream inputStream = Resources.getResourceAsStream(resource);SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);SqlSession sqlSession = sqlSessionFactory.openSession(true);BrandMapper brandMapper = sqlSession.getMapper(BrandMapper.class);Brand brand = new Brand();brand.setId(5);brand.setBrand_name("香飘飘");brand.setCompany_name("香飘飘");brand.setDescription("香飘飘");brand.setOrdered(100);brand.setStatus(1);brandMapper.update(brand);sqlSession.close();}
}
 修改动态字段

实现修改密码功能(想单独改哪个值就改哪个值)

如果调用接口却不给参数,则数据库会出现null值🤦‍♂️

 实现

只需要在SQL语句中添加条件,添加<set>标签

<update id="update">update tb_brand<set><if test="brand_name != null and brand_name != ''">brand_name = #{brand_name},</if><if test="company_name != null and company_name != ''">company_name = #{company_name},</if><if test="ordered != null">ordered = #{ordered},</if><if test="description != null and description != ''">description =#{description},status = #{status}</if>where id = #{id}</set></update>

10、删除

单个删除

Mapper接口

void delete(int id);

 SQL语句

<delete id="delete">delete from tb_brand where id = #{id}</delete>

测试类

public class DeleteTest {public static void main(String[] args) throws IOException, IOException {String resource = "mybatis-config.xml";InputStream inputStream = Resources.getResourceAsStream(resource);SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);SqlSession sqlSession = sqlSessionFactory.openSession(true);BrandMapper brandMapper = sqlSession.getMapper(BrandMapper.class);brandMapper.delete(2);sqlSession.close();}
}
批量删除

 ​​​​​​

 实现

传id数组,sql遍历数组,一个一个删掉

Mapper接口

void deleteByIds(@Param("ids") int[] ids);

 SQL语句

<delete id="deleteByIds">delete from tb_brand where id in<foreach collection="ids" item="id" open="(" separator="," close=")">#{id}</foreach></delete>

 测试类

public class DeleteTest2 {public static void main(String[] args) throws IOException, IOException {String resource = "mybatis-config.xml";InputStream inputStream = Resources.getResourceAsStream(resource);SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);SqlSession sqlSession = sqlSessionFactory.openSession(true);BrandMapper brandMapper = sqlSession.getMapper(BrandMapper.class);int []ids = {5,6};brandMapper.deleteByIds(ids);sqlSession.close();}
}

 注解开发😍

优点:对于简单的SQL语句使用注解开发会非常便捷。

@Select("select * from tb_user where id = #{id}")
public User selectById(int id);

查询:@Select

添加:@Insert

修改:  @Update

删除:@Delete 

缺点:对于复杂的SQL语句应使用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="mapper.BrandMapper"><insert id="add" useGeneratedKeys="true" keyProperty="id">insert into tb_brand(brand_name,company_name,ordered,description,status)values(#{brand_name},#{company_name},#{ordered},#{description},#{status})</insert><update id="update">update tb_brand<set><if test="brand_name != null and brand_name != ''">brand_name = #{brand_name},</if><if test="company_name != null and company_name != ''">company_name = #{company_name},</if><if test="ordered != null">ordered = #{ordered},</if><if test="description != null and description != ''">description =#{description},status = #{status}</if>where id = #{id}</set></update><delete id="delete">delete from tb_brand where id = #{id}</delete><delete id="deleteByIds">delete from tb_brand where id in<foreach collection="ids" item="id" open="(" separator="," close=")">#{id}</foreach></delete><select id="findAll" resultType="pojo.Brand">select * from tb_brand</select><select id="findById" resultType="pojo.Brand">select * from tb_brand where id = #{id}</select><!--    <select id="selectByCondition" resultType="pojo.Brand">-->
<!--        select * from tb_brand-->
<!--        where status = #{status}-->
<!--            and brand_name like #{brand_name}-->
<!--            and company_name like #{company_name}-->
<!--    </select>--><select id="selectByCondition" resultType="pojo.Brand">select * from tb_brand<where><if test="status != null">and status = #{status}</if><if test="brand_name != null and brand_name != ''">and brand_name like #{brand_name}</if><if test="company_name != null and company_name != ''">and company_name like #{company_name}</if></where></select><select id="selectByConditionOne" resultType="pojo.Brand">select * from tb_brandwhere<choose><!--相当于switch--><when test="status != null"><!--相当于case-->status = #{status}</when><when test="brand_name != null and brand_name != ''">brand_name like #{brand_name}</when><when test="company_name != null and company_name != ''">company_name like #{company_name}</when><otherwise><!--当用户一个条件都不给-->1=1</otherwise></choose></select>
</mapper>

 💕完结撒花!💕

 

 

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

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

相关文章

Linux学习笔记6

TFTP 服务器搭建和测试 关于TFTP:TFTP&#xff08;Trivial File Transfer Protocol&#xff0c;简单文件传输协议&#xff09;&#xff0c;是一个基于UDP 协议实现 的用于在客户机和服务器之间进行简单文件传输的协议&#xff0c;适合于开销不大、不复杂的应用场合 搭建服务器…

后量子密码的发展和应用

后量子算法&#xff0c;特别是后量子密码(PQC)&#xff0c;是近年来密码学领域的一个热门话题。随着量子计算技术的快速发展&#xff0c;传统的公钥密码算法面临着被量子计算机破解的威胁。为了应对这一挑战&#xff0c;后量子密码应运而生&#xff0c;成为了一种能够抵抗量子计…

【论文笔记】| 蛋白质大模型ProLLaMA

【论文笔记】| 蛋白质大模型ProLLaMA ProLLaMA: A Protein Large Language Model for Multi-Task Protein Language Processing Peking University Theme: Domain Specific LLM Main work&#xff1a; 当前 ProLLM 的固有局限性&#xff1a;&#xff08;i&#xff09;缺乏自然…

Redis篇 在linux系统上安装Redis

安装Redis 在Ubuntu上安装Redis 在Ubuntu上安装Redis 在linux系统中,我们安装Redis,必须先使它有root权限. 那么在linux中,如何切换到root用户权限呢? sudo su 就可切换到用户权限了. 在切换到用户权限后,我们需要用一条命令来搜索Redis相关的软件包 apt search redis 会出现非…

ROS2学习——节点话题通信(2)

目录 一、ROS2节点 1.概念 2.实例 &#xff08;1&#xff09;ros2 run &#xff08;2&#xff09;ros2 node list &#xff08;3&#xff09;remapping重映射 &#xff08;4&#xff09;ros2 node info 二、话题 &#xff08;1&#xff09; ros2 topic list &#xf…

头歌openGauss-存储过程第1关:创建存储过程

编程要求 1、创建第1个存储过程&#xff0c;并调用&#xff1b; 1&#xff09;创建存储过程&#xff0c;查询emp表数据&#xff1b; 2&#xff09;调用存储过程&#xff1b; --创建存储过程&#xff0c;获得计算机&#xff08;cs&#xff09;系学生选课情况并将结果写入临时表t…

人脸识别:基于卷积神经网络(CNN)分类思想的人脸识别系统

本文来自公众号 “AI大道理” —————— 项目配套视频课程&#xff1a; 平台&#xff1a;荔枝微课 链接&#xff1a;十方教育 项目地址&#xff1a;https://github.com/AIBigTruth/CNN_faces_recognition 之前很多人来询问这个项目怎么做&#xff0c;代码跑不起来&#…

USB数据恢复软件:轻松找回U盘重要数据!

USB数据丢失的原因 USB数据丢失有一些常见原因&#xff0c;了解这些原因有利于恢复数据。 文件意外删除病毒攻击软件错误未安全弹出USB设备格式化USB设备 顺便一提&#xff0c;如果你通过快捷键“Ctrl D”删除了数据&#xff0c;那你可以从回收站中还原它们。如果你永久删除…

Isaac Sim仿真平台学习(1)认识Isaac Sim

0.前言 上一个教程中我们下载好了Isaac Sim&#xff0c;这一章我们将来简单了解一下Isaac Sim平台。 isaac Sim仿真平台安装-CSDN博客 1.Isaac Sim是啥&#xff1f; What Is Isaac Sim? — Omniverse IsaacSim latest documentation Isaac Sim是NVDIA Omniverse平台的机器…

【编译原理复习笔记】属性文法

属性文法 也称为属性翻译文法&#xff0c;由 Knuth 提出&#xff0c;以上下文无关文法为基础 &#xff08;1&#xff09;为每个文法符号&#xff08;终结符与非终结符&#xff09;配备相关的属性&#xff0c;代表与该文法符号相关的信息 &#xff08;2&#xff09;属性文法对于…

数据链路层协议——以太网协议

1. 数据链路层 网络层用于将数据从一台主机发送到另一台主机。传输层用于将数据可靠的从一台主机发送到另一台主机。&#xff08;网络层没有保证可靠性的策略&#xff0c;传输过程中可能会出现各种意外&#xff0c;例如&#xff1a;丢包&#xff0c;网络拥塞等。通过传输层可以…

跨域问题的4种解决方案

文章导读 前言 跨域问题指的是在Web开发中&#xff0c;由于浏览器的同源策略限制&#xff0c;当一个网页尝试访问与它不同源&#xff08;协议、域名或端口不同&#xff09;的资源时&#xff0c;可能会遇到安全限制导致无法正常访问的问题。这种策略旨在防止恶意网站读取或修改其…

订餐系统总结、

应用层&#xff1a; SpringBoot:快速构建Spring项目&#xff0c;采用“约定大于配置”的思想&#xff0c;简化Spring项目的配置开发。 SpringMvc&#xff1a;Spring框架的一个模块&#xff0c;springmvc和spring无需通过中间整合层进行整合&#xff0c;可以无缝集成。 Sprin…

完整的数据可视化方法集

在当前的大数据时代&#xff0c;了解如何可视化数据是UI/UX设计师技能的重要组成部分。如今&#xff0c;几乎所有的公司都需要良好的数据可视化作为确定业务方向和决策的参考。数据的可视化结果越好&#xff0c;用户的决策就越科学。 1、什么是数据可视化 数据可视化是将信息…

张量 t-product 积(matlab代码)

参考文献&#xff1a;Tensor Robust Principal Component Analysis with a New Tensor Nuclear Norm 首先是文章2.3节中 t-product 的定义&#xff1a; 块循环矩阵&#xff1a; 参考知乎博主的例子及代码&#xff1a;&#xff08;t-product与t-QR分解&#xff0c;另一篇傅里叶对…

vue通过for循环生成input框后双向绑定失效问题

有些时候页面上有太多的表单元素&#xff0c;一个个的写太过繁琐&#xff0c;拿 input 框举例&#xff0c;众多的 input 框&#xff0c;无非就是输入框前的说明和 input 框的 name 属性不一样 <el-form :inline"true" :model"formInline" size"mi…

01-05.Vue自定义过滤器

目录 前言过滤器的概念过滤器的基本使用给过滤器添加多个参数 前言 我们接着上一篇文章01-04.Vue的使用示例&#xff1a;列表功能 来讲。 下一篇文章 02-Vue实例的生命周期函数 过滤器的概念 概念&#xff1a;Vue.js 允许我们自定义过滤器&#xff0c;可被用作一些常见的文本…

[协议]stm32读取AHT20程序示例

AHT20温度传感器使用程序&#xff1a; 使用i2c读取温度传感器数据很简单&#xff0c;但市面上有至少两个手册&#xff0c;我这个对应的手册贴出来&#xff1a; main: #include "stm32f10x.h" // Device header #include <stdint.h> #includ…

数智赋能内涝治理,四信城市排水防涝解决方案保障城市安全运行

由强降雨、台风造成城市低洼处出现大量积水、内涝的情况时有发生&#xff0c;给人们出行带来了极大不便和安全隐患&#xff0c;甚至危及群众生命财产安全。 为降低内涝造成的损失&#xff0c;一方面我们要大力加强城市排水基础设施的建设&#xff1b;另一方面要全面掌握城市内涝…

U-Boot menu菜单分析

文章目录 前言目标环境背景U-Boot如何自动调起菜单U-Boot添加自定义命令实践 前言 在某个厂家的开发板中&#xff0c;在进入它的U-Boot后&#xff0c;会自动弹出一个菜单页面&#xff0c;输入对应的选项就会执行对应的功能。如SD卡镜像更新、显示设置等&#xff1a; 目标 本…