【MyBatis】MyBatis 详解

news2024/10/2 14:25:49

MyBatis 详解

  • 一. MyBatis 是什么
  • 二. MyBatis 在整个框架中的定位
  • 三. MyBatis 的操作
    • 1. 先创建好数据库和表
    • 2. 添加MyBatis框架⽀持
    • 3. 修改配置文件
    • 4. 添加业务代码
    • 5. 增、删、改操作
      • ① 增加⽤户
      • ② 修改用户操作
      • ③ 删除操作
    • 6. 查询操作
      • ① 单表查询
      • ② 多表查询

一. MyBatis 是什么

MyBatis 是⼀款优秀的持久层框架,它⽀持⾃定义 SQL、存储过程以及⾼级映射。MyBatis 去除了⼏乎所有的 JDBC 代码以及设置参数和获取结果集的⼯作。MyBatis 可以通过简单的 XML 或注解来配置和映射原始类型、接⼝和 Java 对象为数据库中的记录。
简单来说 MyBatis 是更简单完成程序和数据库交互的⼯具,也就是更简单的操作和读取数据库⼯具。

二. MyBatis 在整个框架中的定位

在这里插入图片描述

MyBatis 也是⼀个 ORM 框架,ORM(Object Relational Mapping),即对象关系映射。在⾯向对象编程语⾔中,将关系型数据库中的数据与对象建⽴起映射关系,进⽽⾃动的完成数据与对象的互相转换:

  • 数据库表(table)–> 类(class)
  • 记录(record,⾏数据)–> 对象(object)
  • 字段(field) --> 对象的属性(attribute)

由图可以看出: MyBatis 包括两个部分:

  • 接口: 定义方法的声明
  • xml 文件: 接口中方法的实现

两者结合生成数据库可执行的 sql, 可以看到 MyBatis 基于 JDBC

三. MyBatis 的操作

1. 先创建好数据库和表

-- 创建数据库
drop database if exists mycnblog;
create database mycnblog DEFAULT CHARACTER SET utf8mb4;
-- 使⽤数据数据
use mycnblog;
-- 创建表[⽤户表]
drop table if exists userinfo;
create table userinfo(
                         id int primary key auto_increment,
                         username varchar(100) not null,
                         password varchar(32) not null,
                         photo varchar(500) default '',
                         createtime datetime default now(),
                         updatetime datetime default now(),
                         `state` int default 1
) default charset 'utf8mb4';
-- 创建⽂章表
drop table if exists articleinfo;
create table articleinfo(
                            id int primary key auto_increment,
                            title varchar(100) not null,
                            content text not null,
                            createtime datetime default now(),
                            updatetime datetime default now(),
                            uid int not null,
                            rcount int not null default 1,
                            `state` int default 1
)default charset 'utf8mb4';
-- 创建视频表
drop table if exists videoinfo;
create table videoinfo(
                          vid int primary key,
                          `title` varchar(250),
                          `url` varchar(1000),
                          createtime datetime default now(),
                          updatetime datetime default now(),
                          uid int
)default charset 'utf8mb4';
-- 添加⼀个⽤户信息
INSERT INTO `mycnblog`.`userinfo` (`id`, `username`, `password`, `photo`,
                                   `createtime`, `updatetime`, `state`) VALUES
    (1, 'admin', 'admin', '', '2021-12-06 17:10:48', '2021-12-06 17:10:48', 1);
-- ⽂章添加测试数据
insert into articleinfo(title,content,uid) values('Java','Java正⽂',1);

-- 添加视频
insert into videoinfo(vid,title,url,uid) values(1,'java title','http://www.baidu.com',1);

2. 添加MyBatis框架⽀持

  1. 已创建的项⽬中添加 MyBatis
        <!-- 添加 MyBatis 框架 -->
        <dependency>
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>mybatis-spring-boot-starter</artifactId>
            <version>2.1.4</version>
        </dependency>
        <!-- 添加 MySQL 驱动 -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.38</version>
            <scope>runtime</scope>
        </dependency>

MyBatis 就像⼀个桥梁,⽽数据库驱动才是真正干活的, 并且数据库驱动有很多种,不⽌有 MySQL,还有 SQL Server、DB2 等等…因此 MyBatis 和 MySQL 驱动这两个都是需要添加的。

  1. 新项⽬添加 MyBatis

新项⽬创建 Spring Boot 项⽬的时候添加引⽤就可以了

在这里插入图片描述

3. 修改配置文件

  1. 数据库连接配置
# 数据库连接配置
spring:
  datasource:
    url: jdbc:mysql://localhost:3306/mycnblog?characterEncoding=utf8&useSSL=false
    username: root
    password: root
    driver-class-name: com.mysql.jdbc.Driver

注意:
如果使⽤ mysql-connector-java 是 5.x 之前的使⽤的是“com.mysql.jdbc.Driver”,如果是⼤于 5.x使⽤的是“com.mysql.cj.jdbc.Driver”。

  1. 配置 MyBatis xml 文件的存放路径
# 配置 mybatis xml 的⽂件路径,在 resources/mapper 目录下创建所有表的 xml ⽂件
mybatis:
  mapper-locations: classpath:mapper/**Mapper.xml

这个 classpath 指当前目录中的 resources 目录

  1. 开启 MyBatis SQL 日志打印
# 开启 MyBatis SQL 打印
# 开启之后可以在控制台上直接看到执行的SQL
#如
#Preparing: insert into userinfo values(?,?,?)
#Parameters: null, laoliu(String), 门头沟(String)
#Updates: 1
# 配置打印 MyBatis 执行的 SQL
mybatis:
  configuration: 
    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl

# 设置日志级别
logging:
  level:
    com:
      example:
        demo: debug


4. 添加业务代码

在这里插入图片描述

  1. ⽤户的实体类:
@Data
public class User {
    private Integer id;
    private String username;
    private String password;
    private String photo;
    private Date createTime;
    private Date updateTime;
}
  1. 添加 mapper 接⼝
@Mapper
public interface UserMapper {
    public List<User> getAll();
}

使用 @Mapper 就不是普通的接口了, 而是 MyBatis 中的接口,可以注入到 Spring Boot 中

  1. 在 resourse/mapper 包下添加 UserMapper.xml

数据持久层的实现,mybatis 的固定 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.example.springboot3.mapper.UserMapper">

</mapper>

UserMapper.xml 查询所有⽤户的具体实现 SQL:

<?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.example.springboot3.mapper.UserMapper">
    <select id="getAll" resultType="com.example.springboot3.model.User">
        select * from userinfo
    </select>
</mapper>

在这里插入图片描述

  1. 添加 服务层 (Service)代码
@Service
public class UserService {
    @Resource
    private UserMapper userMapper;
    public List<User> getAll() {
        return userMapper.getAll();
    }
}

  1. 添加 Controller
@RestController
@RequestMapping("/u")
public class UserController {
    @Resource
    private UserService userService;
    @RequestMapping("/getall")
    public List<User> getAll(){
        return userService.getAll();
    }
}
  1. 使用 postman 进行测试

在这里插入图片描述

5. 增、删、改操作

增加、删除和修改的操作,对应使⽤ MyBatis 的标签如下:

  • <insert>标签:插⼊语句
  • <update>标签:修改语句
  • <delete>标签:删除语句

① 增加⽤户

mapper interface:

    Integer add(User user);

mapper.xml

    <insert id="add">
        insert into userinfo(username,password,photo,state)
        values(#{username},#{password},#{photo},1)
    </insert>

注意:

  • insert into userinfo(username,password,photo,state) 中是数据库中的字段
  • values(#{username},#{password},#{photo},1) 中是类中的属性
  • 当 controller 接收参数时 使用 @RequestParam 注解时, 这里面的 username , password, photo 参数要与 @RequestParam 里面的参数名称一致

service

    public Integer add(User user) {
        return userMapper.add(user);
    }

就算这里面使用的是 对象, 不是直接写的属性, xml 中也直接写属性名称即可, MyBatis 会自动识别,但是注意名称要对应相同

controller

    @RequestMapping(value = "/add",method = RequestMethod.POST)
    public Integer add(@RequestBody User user){
        return userService.add(user);
    }

使用 postman 进行访问

{"username":"mysql","password":"mysql","photo":"img.png"}

在这里插入图片描述

默认返回的是受影响的行数

到数据库中进行查看

在这里插入图片描述

特殊的添加:返回⾃增 id

默认情况下返回的是受影响的⾏号,如果想要返回⾃增 id,具体实现如下。

mapper 接⼝:

    // 添加,返回⾃增id
    void add2(User user);

mapper.xml :

    <!-- 返回自增id -->
    <insert id="add2" useGeneratedKeys="true" keyProperty="id">
        insert into userinfo(username,password,photo,state)
        values(#{username},#{password},#{photo},1)
    </insert>

在这里插入图片描述

service:

    public void add2(User user) {
        userMapper.add(user);
    }

controller:

    @RequestMapping(value = "/add2", method = RequestMethod.POST)
    public Integer add2(@RequestBody User user) {
        userService.add2(user);
        return user.getId();
    }

使用 Postman 进行测试:
在这里插入图片描述
在这里插入图片描述

所以返回自增 id 并不是像返回受影响的行数一样能够直接返回的, 而是放到类的属性中的, 所以想要返回自增 id 就要返回类中对应的属性.

② 修改用户操作

<update id="update">
	update userinfo set username=#{name} where id=#{id}
</update>

③ 删除操作

<delete id="delById" parameterType="java.lang.Integer">
	delete from userinfo where id=#{id}
</delete>

6. 查询操作

① 单表查询

根据⽤户 id 查询⽤户信息的功能

mapper 接口:

    User getUserById(Integer id);

UserMapper.xml:

    <select id="getUserById" resultType="com.example.springboot3.model.User">
        select * from userinfo where id=#{id}
    </select>

service:

    public User getUserById(Integer id) {
        return userMapper.getUserById(id);
    }

controller:

    @RequestMapping("/getuser")
    public User getUserById(Integer id) {
        return userService.getUserById(id);
    }

在这里插入图片描述

② 多表查询

增、删、改返回受影响的⾏数,那么在 mapper.xml 中是可以不设置返回的类型的,然⽽即使是最简单查询⽤户的名称也要设置返回的类型,否则会出错。

  1. 返回类型:resultType

绝⼤数查询场景可以使⽤ resultType 进⾏返回

    <select id="getUserById" resultType="com.example.springboot3.model.User">
        select * from userinfo where id=#{id}
    </select>

优点是使⽤⽅便,直接定义到某个实体类即可。
注意:就算返回的是集合,比如List, resultType 也只需要填写里面实体类的类型 User

  1. 返回字典映射:resultMap

resultMap 使⽤场景:

  • 字段名称和程序中的属性名不同的情况,可使⽤ resultMap 配置映射;
  • ⼀对⼀和⼀对多关系可以使用 resultMap 映射并查询数据。

字段名和属性名不同的情况:比如类的属性为 name, 数据库中字段名为 username

在这里插入图片描述

此时如果直接进行查询:

在这里插入图片描述

这个时候就可以使⽤ resultMap :

    <resultMap id="BaseMap" type="com.example.springboot3.model.User">
        <id property="id" column="id"></id>
        <result property="name" column="username"></result>
    </resultMap>

    <select id="getUserById" resultMap="BaseMap">
        select * from userinfo where id=#{id}
    </select>

在这里插入图片描述

在这里插入图片描述

  1. 多表查询
    在多表查询时,如果使⽤ resultType 标签,在⼀个类中包含了另⼀个对象是查询不出来被包含的对象的, ⽐如以下实体类:
@Data
public class ArticleInfo {
    private Integer id;
    private String title;
    private String content;
    private LocalDateTime createtime;
    private LocalDateTime updatetime;
    private Integer rcount;
    // 包含了 User 对象
    private User user;
}

此时我们就需要使⽤特殊的⼿段来实现联表查询了。

⼀对⼀的表映射:

⼀对⼀映射要使⽤ <association> 标签

    <resultMap id="BaseMap" type="com.example.springboot3.model.ArticleInfo">
        <id property="id" column="id"></id>
        <result property="title" column="title"></result>
        <result property="content" column="content"></result>
        <result property="createtime" column="createtime"></result>
        <result property="updatetime" column="updatetime"></result>
        <result property="rcount" column="rcount"></result>
        <association property="user"
                     resultMap="com.example.springboot3.mapper.UserMapper.BaseMap"
                     columnPrefix="u_">
        </association>
    </resultMap>

    <select id="getAll" resultMap="BaseMap">
        select a.*, u.id  u_id, u.username u_username, u.password u_password, u.photo u_photo,
        u.createtime u_createtime, u.updatetime u_updatetime
        from articleinfo a
        left join userinfo u on a.uid=u.id
    </select>

在这里插入图片描述

  • columnPrefix 属性:绑定⼀对⼀对象时,是通过 columnPrefix + association.resultMap.column 来映射结果集字段。
    association.resultMap.column是指\ 标签中 resultMap属性,对应的结果集映射中,column字段。

columnPrefix 属性不能省略,如果省略当联表中如果有相同的字段,那么就会导致查询出错。
⽐如两篇⽂章都是⼀个⼈写的,如果没有 columnPrefix 就会导致查询的⽤户 id(因为用户表和⽂章表 都有 id 这个字段 相同)查询出错。

ArticleInfo:

@Data
public class ArticleInfo {
    private Integer id;
    private String title;
    private String content;
    private LocalDateTime createtime;
    private LocalDateTime updatetime;
    private Integer rcount;
    // 包含了 User 对象
    private User user;
}

ArticleMapper:

@Mapper
public interface ArticleMapper {
    List<ArticleInfo> getAll();
}

ArticleMapper.xml

    <resultMap id="BaseMap" type="com.example.springboot3.model.ArticleInfo">
        <id column="id" property="id"></id>
        <result column="title" property="title"></result>
        <result column="content" property="content"></result>
        <association property="user"
                     resultMap="com.example.springboot3.mapper.UserMapper.BaseMap">
        </association>
    </resultMap>

    <select id="getAll" resultMap="BaseMap">
        select a.*,u.* from articleinfo a
        left join userinfo u on u.id=a.uid
    </select>

Service:

@Service
public class ArticleService {
    @Resource
    private ArticleMapper articleMapper;

    public List<ArticleInfo> getAll(){
        return articleMapper.getAll();
    }
}

Controller

@RequestMapping("/a")
@RestController
public class ArticleController {
    @Resource
    private ArticleService articleService;
    @RequestMapping("/getall")
    public List<ArticleInfo> getAll() {
        return articleService.getAll();
    }
}

数据库中的数据情况:
在这里插入图片描述

结果:
在这里插入图片描述
明显两篇文章的是同一个作者,但是查询结果不是。

问题 1 解决:使用 columnPrefix
原因是两张表中含有相同的字段,此时不知道将哪个字段赋值给哪个类中的属性所以使用 columnPrefix 属性:

columnPrefix 属性:绑定⼀对⼀对象时,是通过 columnPrefix+association.resultMap.column 来映射结果集字段。
association.resultMap.column是指 <association> 标签中 resultMap属性,对应的结果集映射中,column字段。

问题 2 解决:
属性值不完整的原因是使用 resultMap 是没有将所有的属性到字段的映射关系全部指定出来,
所以,将两个 resultMap 中的映射关系全部显示指定出来即可。

最终的 UserMapper.xml 和 ArticleMapper.xml :

UserMapper.xml

    <resultMap id="BaseMap" type="com.example.springboot3.model.User">
        <id property="id" column="id"></id>
        <result property="name" column="username"></result>
        <result property="password" column="password"></result>
        <result property="photo" column="photo"></result>
        <result property="createTime" column="createtime"></result>
        <result property="updateTime" column="updatetime"></result>
    </resultMap>

ArticleMapper.xml

    <resultMap id="BaseMap" type="com.example.springboot3.model.ArticleInfo">
        <id property="id" column="id"></id>
        <result property="title" column="title"></result>
        <result property="content" column="content"></result>
        <result property="createtime" column="createtime"></result>
        <result property="updatetime" column="updatetime"></result>
        <result property="rcount" column="rcount"></result>
        <association property="user"
                     resultMap="com.example.springboot3.mapper.UserMapper.BaseMap"
                     columnPrefix="u_">
        </association>
    </resultMap>

    <select id="getAll" resultMap="BaseMap">
        select a.*, u.id  u_id, u.username u_username, u.password u_password, u.photo u_photo,
        u.createtime u_createtime, u.updatetime u_updatetime
        from articleinfo a
        left join userinfo u on a.uid=u.id
    </select>

在这里插入图片描述

注意:

  • 只增加一个 columnPrefix=“u_” 是不行的,这只是指出来查询的结果中 User 对应表中的字段会有 u_ 前缀,从而让程序能够区分
  • 并不是真正的加上了前缀,只是指出了带 u_ 前缀的是 User 对应的表
  • 所以我们自己要在后面的查询语句中对 user 表中查询的属性加上 u_

从上面代码看出来, 如果使用了 columnPrefix 这个属性的话, 需要将要查询出来的每一个字段都重命名, 添上前缀, 所以当要查询出来的属性比较多时, 是比较冗长的.

当然也可以不使用 /这种方式: 使用一个新的类去接收结果

比如

@Data
public class ArticleInfo {
    private Integer id;
    private String title;
    private String content;
    private LocalDateTime createtime;
    private LocalDateTime updatetime;
    private Integer rcount;
}

但是查询结果中需要由对应文章的作者名称, 那么就创建一个新的类继承 ArticleInfo 类:

@Data
public class ArticleInfoVO extends ArticleInfo{
    private String username;
}

mapper.xml

    <select id="getArticleinfo" resultType="com.example.springboot3.model.ArticleInfoVO">
        select a.*, u.username from articleinfo a left join userinfo u on a.uid = u.id
    </select>

这样就简单的多了

⼀对多:⼀个⽤户多篇⽂章

⼀对多需要使⽤ <collection> 标签,⽤法和 <association> 相同

@Data
public class UserInfo {
    private Integer id;
    private String name;
    private String password;
    private String photo;
    private Date createTime;
    private Date updateTime;
    // 文章列表
    private List<ArticleInfo> alist;
}
    <resultMap id="BaseMap" type="com.example.springboot3.model.UserInfo">
        <id column="id" property="id" />
        <result column="username" property="name"></result>
        <result column="password" property="password"></result>
        <result column="photo" property="photo"></result>
        <result column="createtime" property="createTime"></result>
        <result column="updatetime" property="updateTime"></result>
        <collection property="alist" resultMap="com.example.springboot3.mapper.ArticleMapper.BaseMap"
                    columnPrefix="a_">
        </collection>
    </resultMap>

    <select id="getUserById" resultMap="BaseMap">
        select u.*, a.id a_id, a.title a_title, a.content a_content, a.createtime a_createtime,
               a.updatetime a_updatetime, a.rcount a_rcount
        from userinfo u
        left join articleinfo a on u.id=a.uid where u.id=#{id}
    </select>

一对多也可以不使用 <collection>这种方式,也使用一个新的类去接收结果

好啦! 以上就是对 MyBatis 的讲解,希望能帮到你 !
评论区欢迎指正 !

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

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

相关文章

Ubuntu16.04apt更新失败

先设置网络设置 换成nat、桥接&#xff0c;如果发现都不行&#xff0c;那么就继续下面操作 1.如果出现一开始就e&#xff0c;检查源&#xff0c;先换源 2.换完源成功之后&#xff0c;ping网络&#xff0c;如果ping不通就是网络问题 如果ping baidu.com ping不通但是ping 112…

2023年中国非晶带材产量、竞争现状及行业市场规模前景分析[图]

非晶带材指生产工艺采用急速冷却技术将含铁、硅、硼等元素的合金熔液以每秒百万度的速度快速冷却后得到的带材&#xff0c;其物理状态表现为金属原子呈长程无序的非晶体排列。非晶带材及其制品非晶铁心主要用于电力领域&#xff0c;是非晶配电变压器的主要用材及核心部件。 我国…

Git入门详解

Git入门详解 本文承接上文 Git入门简介 并做了内容扩充。本文讲述Git工具的安装、配置及使用友情参考链接&#xff1a;https://gitee.com/all-about-git 1. Git安装 安装官网&#xff1a;https://git-scm.com/安装过程如下&#xff1a; 双击.exe默认安装即可 2. Git配置 …

基于DBC Signal Group生成Autosar SR接口(1)

文章目录 前言实现方法结构体在Simulink中的定义SignalGroup提取 总结 前言 在开发Autosar CAN通信模块时&#xff0c;对于Signal Group需要建立对应的Interface,其中的数据类型实际是一个结构体&#xff0c;包含Group中的Signal的数据类型定义。手动建立比较费时间&#xff0…

2023年中国人防服务需求现状及行业市场规模前景分析[图]

人防服务指利用人发现风险事件&#xff0c;并延迟或阻止风险事件的发生&#xff0c;在自身力量不足的情况下发出应急救援信号&#xff0c;以待做出进一步的反应&#xff0c;制止风险事件的发生或处理已发生的风险事件。人防服务是保安服务公司最基本的业务内容。2022年国内保安…

日常学习收获之----react的ref和wrappedComponentRef的区别

react获取子组件的方式&#xff0c;有ref和wrappedComponentRef。那这两者有什么区别呢&#xff1f; 区别在于是否用了高阶组件&#xff01;&#xff01;&#xff01;&#xff01;&#xff01;&#xff01;&#xff01;&#xff01;&#xff01;&#xff01;&#xff01;&#…

中国鞋业品牌步力宝:传统制造业蜕变为资本上市公司的光辉征程

​中国鞋业&#xff0c;作为典型的劳动密集型产业&#xff0c;一直在不断演进。从最初的皮鞋、布鞋、胶鞋、塑料鞋&#xff08;化学鞋&#xff09;四大类鞋&#xff0c;到今天的复杂多样&#xff0c;中国鞋业一直在追求更高的品质和创新。随着社会的进步和科学技术的发展&#…

第二证券:临时停牌一般多久?

随着股票买卖市场的日益开展&#xff0c;股票买卖的监管也越来越严格。而前段时刻&#xff0c;上市公司中多家公司被暂时停牌&#xff0c;此举引起了公众对于暂时停牌时刻的重视。那么&#xff0c;暂时停牌一般多久&#xff1f;本篇文章将从多个视点出发&#xff0c;对这一问题…

迅为RK3568开发板Scharr滤波器算子边缘检测

本小节代码在配套资料“iTOP-3568 开发板\03_【iTOP-RK3568 开发板】指南教程\04_OpenCV 开发配套资料\33”目录下&#xff0c;如下图所示&#xff1a; 在 Sobel 算子算法函数中&#xff0c;如果设置 ksize-1 就会使用 3x3 的 Scharr 滤波器。Scharr 算子是 Soble 算子在 ksize…

基于Python和Tkinter的双目相机驱动界面

文章目录 前言准备工作代码分析初始化创建按钮创建图像显示区域创建信息标签启动摄像头捕捉主函数结论效果展示 前言 本文将介绍如何使用Python和Tkinter库来创建一个简单的摄像头应用程序。这个应用程序可以打开摄像头&#xff0c;显示摄像头捕捉的图像&#xff0c;并允许用户…

Nosql redis高可用和持久化

Nosql redis高可用和持久化 1、redis高可用2、redis持久化2.1redis持久化2.2Redis 持久化方法2.3RDB 持久化2.3.1RDB持久化工作原理2.3.2触发条件2.3.3其他自动触发机制2.3.4执行流程2.3.5启动时加载 2.4AOF 持久化2.4.1AOF持久化原理2.4.2开启AOF2.4.3执行流程2.4.4文件重写的…

8+结合10种机器学习算法构建模型,可复现。

今天给同学们分享一篇机器学习的生信文章“Comprehensive machine-learning survival framework develops a consensus model in large-scale multicenter cohorts for pancreatic cancer”&#xff0c;这篇文章于2022年10月25日发表在eLife期刊上&#xff0c;影响因子为8.713。…

小游戏开发者应该如何入局赛道

一、微信小游戏赛道发展史 第一阶段&#xff1a;轻度试水期&#xff0c;2017&#xff5e;2019年 微信小游戏于2017年底上线&#xff0c;初期以轻度休闲为主&#xff0c;例如棋牌、合成消除以及益智相关游戏类型。一是开发门槛不高&#xff0c;产品可以快速上线; 二是大部分厂…

功率信号源在电子测试中的应用有哪些方面

功率信号源在电子测试中有着广泛的应用&#xff0c;可以提供稳定、可调的功率信号&#xff0c;用于各种测量和验证工作。下面西安安泰将介绍功率信号源在电子测试中的几个主要应用方面。 图&#xff1a;ATG-2000系列功率信号源 无线通信测试&#xff1a;功率信号源在无线通信测…

【three.js】结合vue进行开发第一个3d页面

一、创建vue项目 新建一个项目目录&#xff0c;在集成终端打开&#xff0c;输入 npm init vitelatest 回车后&#xff0c;依次输入项目名&#xff0c;选择vue和js开发 然后安装依赖并运行项目 二、安装three 接下来我们开始安装three npm install three 三、Three.js 的…

【Unity3D赛车游戏制作】开始场景搭建——UGUI复合控件Button

&#x1f468;‍&#x1f4bb;个人主页&#xff1a;元宇宙-秩沅 &#x1f468;‍&#x1f4bb; hallo 欢迎 点赞&#x1f44d; 收藏⭐ 留言&#x1f4dd; 加关注✅! &#x1f468;‍&#x1f4bb; 本文由 秩沅 原创 &#x1f468;‍&#x1f4bb; 收录于专栏&#xff1a;Uni…

leetcode 每日一题复盘(10.9~10.15)

leetcode 101 对称二叉树 这道题一开始想是用层序遍历,看每一层是否都对称,遇到一个问题就是空指针(子树为空)无法记录下来,同时会导致操作空指针的问题,因此需要修改入队条件,并用一个标志去表示空指针 vector<int>numv;for(int i0;i<size;i){TreeNode*frontque.fro…

JavaScript ES5实现继承

一、对象和函数的原型 1.认识对象的原型 JavaScript当中每个对象都有一个特殊的内置属性 [[prototype]]&#xff0c;这个特殊的对象可以指向另外一个对象。 那么这个对象有什么用呢&#xff1f; 当我们通过引用对象的属性key来获取一个value时&#xff0c;它会触发 **[[Get…

uni-app:实现页面效果4(echarts数据可视化)

效果 代码 <template><view><view><view class"title">概况</view><view class"line_position"><view class"line1"><view class"item"><view class"one">今日销售…