【Java开发】 Springboot集成Mybatis-Flex

news2024/9/22 5:34:18

1 Mybatis-Flex 介绍


1.1简介

        Mybatis-Flex 是一个优雅的 Mybatis 增强框架,它非常轻量、同时拥有极高的性能与灵活性。我们可以轻松的使用 Mybaits-Flex 链接任何数据库,其内置的 QueryWrapper 亮点帮助我们极大的减少了 SQL 编写的工作的同时,减少出错的可能性。

1.2特征

        1.轻量:除了 MyBatis,没有任何第三方依赖、没有任何拦截器,在执行的过程中,没有任何的 Sql 解析(Parse)。 这带来了几个好处:极高的性能、极易对代码进行跟踪和调试、把控性更高。
        2.灵活:支持 Entity 的增删改查、以及分页查询的同时,MyBatis-Flex 提供了 Db + Row 工具,可以无需实体类对数据库进行增删改查以及分页查询。 与此同时,MyBatis-Flex 内置的 QueryWrapper 可以轻易的帮助我们实现 多表查询、链接查询、子查询 等等常见的 SQL 场景。
        3.强大:支持任意关系型数据库,还可以通过方言持续扩展,同时支持 多(复合)主键、逻辑删除、乐观锁配置、数据脱敏、数据审计、 数据填充 等等功能。


简单来说,Mybatis-Flex 相比 Mybatis-Plus 等框架 速度更快、功能更多、代码更简洁~

1.3Mybatis-Flex和同类框架对比

1)功能对比:

2)性能对比:
这里直接贴测试结果:

MyBatis-Flex 的查询单条数据的速度,大概是 MyBatis-Plus 的 5 ~ 10+ 倍。
MyBatis-Flex 的查询 10 条数据的速度,大概是 MyBatis-Plus 的 5~10 倍左右。
Mybatis-Flex 的分页查询速度,大概是 Mybatis-Plus 的 5~10 倍左右。
Mybatis-Flex 的数据更新速度,大概是 Mybatis-Plus 的 5~10+ 倍。

 

2 准备工作

官方文档:快速开始 - MyBatis-Flex

以 Spring Boot + Maven + Mysql 项目做演示

2.1 数据库中创建表及插入数据

此处省略~

2.2 Spring Boot 项目初始化

此时需要创建 Spring Boot 项目,并添加 Maven 依赖;此处我通过 IDEA 使用 Spring Initializer 快速初始化一个 Spring Boot 工程。

项目创建省略~

2.3 添加 Maven 主要依赖

往 pom.xml 文件中添加以下依赖。

<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>



        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
        </dependency>
        <dependency>
            <groupId>com.mybatis-flex</groupId>
            <artifactId>mybatis-flex-spring-boot-starter</artifactId>
            <version>1.7.3</version>
        </dependency>
        <dependency>
            <groupId>com.mybatis-flex</groupId>
            <artifactId>mybatis-flex-processor</artifactId>
            <version>1.7.3</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
        </dependency>
        <!--++++++++++++++++++++++++++++++++++++++++++++++++++++-->
        <!-- MyBatis分页插件 -->
        <!--++++++++++++++++++++++++++++++++++++++++++++++++++++-->
        <dependency>
            <groupId>com.github.pagehelper</groupId>
            <artifactId>pagehelper</artifactId>
            <version>5.3.0</version>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.12.0</version>
        </dependency>

2.4 配置数据源

在 application.properties 或 application.yml 中配置数据源:


server.port=8999

spring.application.name=mybatisPlus

spring.datasource.username=root
spring.datasource.password=root3306
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/mybatis_plus?useSSL=false&useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver

3 Mybatis-Flex 实践

3.1 编写实体类和 Mapper 接口

📌 User 实体类

  • 使用 @Table("flex_user") 设置实体类与表名的映射关系
  • 使用 @Id(keyType = KeyType.Auto) 标识主键为自增
package com.mybatisflex.flex.domain;

import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Table;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.Date;

/** 
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
//使用 @Table("tb_account") 设置实体类与表名的映射关系
@Table("user")
public class User implements Serializable {
    private Integer id;

    @Column(value = "name")
    private String name;
    @Column(value = "age")
    private Integer age;
    @Column(value = "email")
    private String email;
    @Column(value = "create_time", onInsertValue = "now()")
    private Date createTime;
    @Column(value = "update_time", onUpdateValue = "now()")
    private Date updateTime;
    @Column(value = "del_flag")
    private int delFlag;

    @Column(value = "dept_code")
    private String deptCode;
}

📌 Mapper 接口继承 BaseMapper 接口

package com.mybatisflex.flex.mapper;

import com.mybatisflex.core.BaseMapper;
import com.mybatisflex.flex.domain.User;

/**
 * 
 */
public interface UserMapper extends BaseMapper<User> {
}

3.2 在主启动类添加 @MapperScan 注解

用于扫描 Mapper 文件夹:

package com.mybatisflex.flex;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
@MapperScan("com.mybatisflex.flex.mapper")
public class FlexApplication {

    public static void main(String[] args) {
        SpringApplication.run(FlexApplication.class, args);
    }

}

3.3 创建service

package com.mybatisflex.flex.service;

import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.core.update.UpdateChain;
import com.mybatisflex.flex.domain.User;
import com.mybatisflex.flex.domain.UserDto;
import com.mybatisflex.flex.domain.table.SysDeptTableDef;
import com.mybatisflex.flex.domain.table.UserTableDef;
import com.mybatisflex.flex.mapper.UserMapper;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Description:
 * @Date Create in 10:39 2023/11/22
 * @Modified By:
 */

@Service
public class UserService extends ServiceImpl<UserMapper, User> {
    /**
     * 查询全部
     * @return
     */
    public List<User> selectAll(){
        return this.getMapper().selectAll();
    }


    public List<User> selectList(){
        QueryWrapper wrapper = QueryWrapper.create()
                // 这里可以指定查询字段
                .select()
                // sql from表名
                .from(User.class)
                .where(User::getName).like("徐")
                .or(UserTableDef.USER.ID.in(2,3).and(UserTableDef.USER.NAME.like("o")));
        return this.getMapper().selectListByQuery(wrapper);
    }

    /**
     * 根据userId获取User数据
     * @param userId
     * @return
     */
    public User listById(Integer userId){
        QueryWrapper wrapper = QueryWrapper.create()
                // 这里可以指定查询字段
                .select()
                // sql from表名
                .from(User.class)
                .where(User::getId).eq(userId).and(User::getName).like("徐");
        return this.getMapper().selectOneByQuery(wrapper);
    }

    /**
     * 关联查询--链式查询
     */
    public List<UserDto> getInfo(Integer userId){
        QueryWrapper query = QueryWrapper.create()
                .select(UserTableDef.USER.ALL_COLUMNS)
                .select(SysDeptTableDef.SYS_DEPT.DEPT_NAME)
                .from(UserTableDef.USER).as("u")
                .leftJoin(SysDeptTableDef.SYS_DEPT).as("d").on(UserTableDef.USER.DEPT_CODE.eq(SysDeptTableDef.SYS_DEPT.DEPT_CODE))
                .where(UserTableDef.USER.ID.eq(userId));
        return this.getMapper().selectListByQueryAs(query,UserDto.class);
    }

    /**
     * 新增
     * @param user
     */
    public void insert(User user){
        this.getMapper().insert(user);
    }

    /**
     * 更新User
     * @param user
     */
    public void updateEntity(User user){
        this.getMapper().update(user);
    }

    /**
     * 局部更新
     * @param userId
     * @param userName
     */
    public void updateRow(Integer userId, String userName){
        UpdateChain.of(User.class)
                .set(User::getName, userName)
                .where(User::getId).eq(userId).update();
    }

    /**
     * 删除
     * @param userName
     */
    public void deleteByWrapper(String userName){
        QueryWrapper queryWrapper = QueryWrapper.create().where(User::getName).eq(userName);
        this.getMapper().deleteByQuery(queryWrapper);
    }

}

3.4创建Controller接口测试

package com.mybatisflex.flex.controller;

import com.mybatisflex.flex.domain.User;
import com.mybatisflex.flex.domain.UserDto;
import com.mybatisflex.flex.page.TableDataInfo;
import com.mybatisflex.flex.service.UserService;
import com.mybatisflex.flex.utils.ResponseUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author: best_liu
 * @Description:
 * @Date Create in 10:33 2023/11/22
 * @Modified By:
 */
@RestController
@RequestMapping("/user")
public class SysUserController {

    @Resource
    private UserService userService;

    /**
     * 查询全部
     * @return
     */
    @GetMapping("listall")
    public List<User> listall(){
        return userService.selectAll();
    }

    /**
     * 分页查询
     * @return
     **/
    @GetMapping("/page")
    public TableDataInfo findPage() {
        ResponseUtils.startPage();
        return ResponseUtils.getDataTable(userService.selectAll());
    }


    /**
     * 按条件查询
     * @return
     */
    @GetMapping("getList")
    public List<User> selectList(){
        return userService.selectList();
    }

    /**
     * 按userId查询
     * @return
     */
    @GetMapping("listById")
    public User listById(){
        return userService.listById(0);
    }

    /**
     * 按userId关联查询部门
     * @return
     */
    @GetMapping("getInfo")
    public List<UserDto> getInfo(){
        return userService.getInfo(0);
    }

    /**
     * 新增
     * @return
     */
    @GetMapping("insert")
    public Boolean insert(){
        User user = User.builder().id(10).name("张三").age(100).email("zhangsan@163.com").build();
        userService.insert(user);
        return Boolean.TRUE;
    }

    /**
     * 更新
     * @return
     */
    @GetMapping("update")
    public Boolean update(){
        userService.updateRow(10, "张三三");
        return Boolean.TRUE;
    }

    /**
     * 删除
     * @return
     */
    @GetMapping("delete")
    public Boolean delete(){
        userService.deleteByWrapper("张三三");
        return Boolean.TRUE;
    }
}

4 链式查询

若想使用链式查询还得需要 APT 配置,MyBatis-Flex 使用了 APT(Annotation Processing Tool)技术,在项目编译的时候,会自动根据 Entity/pojo 类定义的字段帮你生成 "USER" 类(可用于链式查询)

通过开发工具构建项目(如下图),或者执行 maven 编译命令: mvn clean package 都可以自动生成。

正常情况下,会在 target 包下生成如下资源

若生成该资源并导入成功,那么此时,可使用链式查询

/**
     * 关联查询
     */
    public List<UserDto> getInfo(Integer userId){
        QueryWrapper query = QueryWrapper.create()
                .select(UserTableDef.USER.ALL_COLUMNS)
                .select(SysDeptTableDef.SYS_DEPT.DEPT_NAME)
                .from(UserTableDef.USER).as("u")
                .leftJoin(SysDeptTableDef.SYS_DEPT).as("d").on(UserTableDef.USER.DEPT_CODE.eq(SysDeptTableDef.SYS_DEPT.DEPT_CODE))
                .where(UserTableDef.USER.ID.eq(userId));
        return this.getMapper().selectListByQueryAs(query,UserDto.class);
    }

总的来说,MyBatis-Flex 的链式查询相比 MyBatis-Plus 多了一步配置环节,目前来看其他步骤类似。

MyBatis-Flex/Plus 代码对比

接下来看一下MyBatis-Flex  MyBatis-Plus 各部分功能代码的差别,Employee、Account、Article 都是实体类。

5.1 基础查询

MyBatis-Flex:

QueryWrapper query = QueryWrapper.create()
        .where(EMPLOYEE.LAST_NAME.like(searchWord)) //条件为null时自动忽略
        .and(EMPLOYEE.GENDER.eq(1))
        .and(EMPLOYEE.AGE.gt(24));
List<Employee> employees = employeeMapper.selectListByQuery(query);

MyBatis-Plus:

QueryWrapper<Employee> queryWrapper = Wrappers.query()
        .like(searchWord != null, "last_name", searchWord)
        .eq("gender", 1)
        .gt("age", 24);
List<Employee> employees = employeeMapper.selectList(queryWrapper);
 
//lambda 写法:
LambdaQueryWrapper<Employee> queryWrapper = Wrappers.<Employee>lambdaQuery()
        .like(StringUtils.isNotEmpty(searchWord), Employee::getUserName,"B")
        .eq(Employee::getGender, 1)
        .gt(Employee::getAge, 24);
List<Employee> employees = employeeMapper.selectList(queryWrapper);

5.2 集合查询

MyBatis-Flex:

QueryWrapper query = QueryWrapper.create()
    .select(
        ACCOUNT.ID,
        ACCOUNT.USER_NAME,
        max(ACCOUNT.BIRTHDAY),
        avg(ACCOUNT.SEX).as("sex_avg")
    );
List<Employee> employees = employeeMapper.selectListByQuery(query);

MyBatis-Plus:

QueryWrapper<Employee> queryWrapper = Wrappers.query()
    .select(
        "id",
        "user_name",
        "max(birthday)",
        "avg(birthday) as sex_avg"
    );
List<Employee> employees = employeeMapper.selectList(queryWrapper);

缺点:字段硬编码,容易拼错。无法使用 IDE 的字段进行重构,无法使用 IDE 自动提示,发生错误不能及时发现,不过MyBatis-Plus的 lambdawrapper 也是能解决这个问题。

5.3 and(...) 和 or(...)

假设我们要构建如下的 SQL 进行查询(需要在 SQL 中添加括号)。

SELECT * FROM tb_account
WHERE id >= 100
AND (sex = 1 OR sex = 2)
OR (age IN (18,19,20) AND user_name LIKE "%michael%" )

MyBatis-Flex:

QueryWrapper query = QueryWrapper.create()
    .where(ACCOUNT.ID.ge(100))
    .and(ACCOUNT.SEX.eq(1).or(ACCOUNT.SEX.eq(2)))
    .or(ACCOUNT.AGE.in(18, 19, 20).and(ACCOUNT.USER_NAME.like("michael")));

MyBatis-Plus:

QueryWrapper<Employee> query = Wrappers.query()
        .ge("id", 100)
        .and(i -> i.eq("sex", 1).or(x -> x.eq("sex", 2)))
        .or(i -> i.in("age", 18, 19, 20).like("user_name", "michael"));
// or lambda
LambdaQueryWrapper<Employee> query = Wrappers.<Employee>lambdaQuery()
        .ge(Employee::getId, 100)
        .and(i -> i.eq(Employee::getSex, 1).or(x -> x.eq(Employee::getSex, 2)))
        .or(i -> i.in(Employee::getAge, 18, 19, 20).like(Employee::getUserName, "michael"));

5.4 多表查询

MyBatis-Flex:

QueryWrapper query = QueryWrapper.create()
    .select().from(ACCOUNT)
    .leftJoin(ARTICLE).on(ACCOUNT.ID.eq(ARTICLE.ACCOUNT_ID))
    .where(ACCOUNT.AGE.ge(10));
 
List<Account> accounts = mapper.selectListByQuery(query);
QueryWrapper query = new QueryWrapper()
.select(
      ACCOUNT.ID
    , ACCOUNT.USER_NAME
    , ARTICLE.ID.as("articleId")
    , ARTICLE.TITLE)
.from(ACCOUNT.as("a"), ARTICLE.as("b"))
.where(ACCOUNT.ID.eq(ARTICLE.ACCOUNT_ID));

MyBatis-Plus:不支持

5.5 部分字段更新

假设一个实体类 Account 中,我们要更新其内容如下:

  • userName 为 "michael"
  • age 为 "18"
  • birthday 为 null

其他字段保持数据库原有内容不变,要求执行的 SQL 如下:

update tb_account
set user_name = "michael", age = 18, birthday = null
where id = 100

MyBatis-Flex 代码如下:

Account account = UpdateEntity.of(Account.class);
account.setId(100); //设置主键
account.setUserName("michael");
account.setAge(18);
account.setBirthday(null);
 
accountMapper.update(account);

MyBatis-Plus 代码如下(或可使用 MyBatis-Plus 的 LambdaUpdateWrapper,但性能没有 UpdateWrapper 好):

UpdateWrapper<Account> updateWrapper = new UpdateWrapper<>();
updateWrapper.eq("id", 100);
updateWrapper.set("user_name", "michael");
updateWrapper.set("age", 18);
updateWrapper.set("birthday", null);
 
accountMapper.update(null, updateWrapper);

如上,MyBatis-Flex 在代码编写来说更加灵活,编写方式更多一些,还是有些优势。

源码地址:https://download.csdn.net/download/askuld/88561026 

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

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

相关文章

微信订房功能怎么做_公众号里怎么实现在线订房系统

微信公众号在线订房系统&#xff1a;一键解决您的住宿问题 在当今数字化时代&#xff0c;微信公众号已经成为人们生活中不可或缺的一部分。它提供了各种各样的功能和服务&#xff0c;让我们的生活变得更加便捷和高效。而如今&#xff0c;微信公众号也实现了在线订房功能&#…

SecureCRT -- 使用说明

【概念解释】什么是SSH&#xff1f; SSH的英文全称是Secure Shell 传统的网络服务程序&#xff0c;如&#xff1a;ftp和telnet在本质上都是不安全的&#xff0c;因为它们在网络上用明文传送口令和数据&#xff0c;别有用心的人非常容易就可以截获这些口令和数据。而通过使用SS…

8年老鸟整理,自动化测试-准备测试数据详细...

目录&#xff1a;导读 前言一、Python编程入门到精通二、接口自动化项目实战三、Web自动化项目实战四、App自动化项目实战五、一线大厂简历六、测试开发DevOps体系七、常用自动化测试工具八、JMeter性能测试九、总结&#xff08;尾部小惊喜&#xff09; 前言 大部分类型的测试…

拆解现货黄金隔夜利息计算公式

在讨论现货黄金投资手续费的时候&#xff0c;隔夜利息是经常被忽略的一个方面&#xff0c;但它是投资者不得不考虑的成本因素&#xff0c;特别是在中长线交易的情况下。隔夜利息是根据投资者的持仓数量和交易方向所计算出的利息&#xff0c;如果投资者需要持仓过夜&#xff0c;…

程序员的护城河:技术深度、创新追求与软实力的综合构筑

在IT行业&#xff0c;程序员被形象地比喻为现代社会的护城河&#xff0c;他们以代码为武器&#xff0c;捍卫着系统安全、数据防护以及网络稳定。然而&#xff0c;这位"护城河"究竟是依赖于技术深度、创新追求&#xff0c;还是软实力中的沟通协作等方面呢&#xff1f;…

【vue】ant-design-vue的树结构实现节点增删改查

根据业务需要&#xff0c;实现树结构的节点新增编辑删除功能&#xff0c;主要逻辑是利用树节点的scopedSlots属性对其进行自定义改造&#xff0c;监听悬停事件在节点右侧出现增删改对应图标&#xff0c;点击图标出现弹窗表单对内容进行修改&#xff0c;具体代码如下&#xff1a…

TikTok Shop订单狂涨,黑五全托管品类日卖爆了

01 黑五品类日爆单 显然&#xff0c;TikTok Shop在美国的首个黑五大促收获了胜利的果实。 根据最新发布的数据&#xff0c;TikTok Shop全托管黑五六大品类日支付GMV&#xff08;总交易额&#xff09;和支付量双双实现大幅度增长。举其中几个具体数据来看&#xff0c;女装童鞋…

【腾讯云云上实验室-向量数据库】腾讯云开创新时代,发布全新向量数据库Tencent Cloud VectorDB

前言 随着人工智能、数据挖掘等技术的飞速发展&#xff0c;海量数据的存储和分析越来越成为重要的研究方向。在海量数据中找到具有相似性或相关性的数据对于实现精准推荐、搜索等应用至关重要。传统关系型数据库存在一些缺陷&#xff0c;例如存储效率低、查询耗时长等问题&…

服务案例|故障频发的一周,居然睡得更香!

医院运维有多忙&#xff1f; 医院运维&#xff0c;听起来平平无奇毫不惊艳&#xff0c;但其中的含金量&#xff0c;可不是“维持系统正常运行”就能总结的。毕竟医院对业务连续性的超高要求&#xff0c;让运维面对的问题都是暂时的&#xff0c;下一秒可能就有新问题需要发现解…

CountDownLatch和CyclicBarrier

JUC&#xff08;Java.util.concurrent&#xff09;是Java 5中引入的一个并发编程库&#xff0c;它包含了许多用于多线程处理的工具类和接口。JUC主要提供了以下特性&#xff1a; 线程池&#xff1a;线程池可以提高线程的使用效率&#xff0c;避免频繁地创建和销毁线程&#xff…

许战海战略文库|从丰田到等离子屏:技术领先为何失去市场?

引言&#xff1a;在探讨技术创新与市场需求之间的微妙关系时&#xff0c;个关键的问题浮现:为什么强大的技术优势并不总是等同于市场成功?从丰田汽车在电动车领域的挑战到日本等离子显示屏技术的衰落,市场趋势对企业成功存在决定性影响。企业需要在技术创新和市场需求之间找到…

聚焦数字化项目管理——2023年PMI项目管理大会亮点回顾

11月18日-19日&#xff0c;由PMI&#xff08;中国&#xff09;主办的2023年PMI项目管理大会在上海浦东嘉里大酒店圆满召开。本次大会以“数智时代&#xff0c;汇创未来”为主题&#xff0c;聚焦数智时代大背景下的项目管理行业发展和人才培养&#xff0c;吸引了海内外千余名项目…

9.3 Windows驱动开发:内核解析PE结构节表

在笔者上一篇文章《内核解析PE结构导出表》介绍了如何解析内存导出表结构&#xff0c;本章将继续延申实现解析PE结构的PE头&#xff0c;PE节表等数据&#xff0c;总体而言内核中解析PE结构与应用层没什么不同&#xff0c;在上一篇文章中LyShark封装实现了KernelMapFile()内存映…

AIGC变革BI行业,永洪发布vividime全球化品牌

大数据产业创新服务媒体 ——聚焦数据 改变商业 国内BI商业智能市场&#xff0c;一直有着“内永洪&#xff0c;外Tableau”的说法。成立于2012年的永洪科技经过十多年的发展&#xff0c;早已崛起为国内大数据行业的一支劲旅。 ChatGPT火爆出圈之后&#xff0c;AIGC快速渗透&am…

身份证号码校验

根据《新版外国人永久居留身份证适配性改造要点》&#xff0c;公司需要把代码中对身份证的校验进行优化 就文档内容可以看到需要优化的要点是&#xff1a; 新版永居证号码以 9 开头 受理地区代码出生日期顺序码校验码&#xff1b;&#xff08;共18位&#xff09; eg&#xff…

栈的生长方向不总是向下

据我了解&#xff0c;栈的生长方向向下&#xff0c;内存地址由高到低 测试 windows下&#xff1a; 符合上述情况 测试Linux下&#xff1a; 由此可见&#xff0c;栈在不同操作系统环境下&#xff0c;生长方向不总是向下

jetpack compose中实现丝滑的轮播图效果

写在前面 最近在翻Jetpack库&#xff0c;发现了DataStore&#xff0c;官方是这么说的&#xff1a; Jetpack DataStore 是一种数据存储解决方案&#xff0c;允许您使用协议缓冲区存储键值对或类型化对象。DataStore 使用 Kotlin 协程和 Flow 以异步、一致的事务方式存储数据。 …

18张值得收藏的高清卫星影像

这里分享的18张高清卫星影像&#xff0c;由吉林一号卫星拍摄。 原图来自长光卫星嘉宾在直播中分享的PPT演示文档。 18张高清卫星影像 吉林一号高分04A星&#xff0c;于2022年05月21日拍摄的北京紫禁城高清卫星影像。 北京紫禁城 云南昆明滇池国际会展中心高清卫星影像&…

劲松HPV防治诊疗中心提醒:做完HPV检查后,需留意这些事项!

在接受HPV检查后&#xff0c;有一些注意事项需要您注意。首先&#xff0c;要遵循医生的建议&#xff0c;并按照医生的指示进行后续治疗和随访。 其次&#xff0c;检查后可能会有些不适感&#xff0c;这是正常的现象&#xff0c;不必过于担心。但是&#xff0c;如果不适感持续加…

枚举 蓝桥oj DNA序列修正

题目详情&#xff1a; 简单翻译&#xff1a; 主要思路&#xff1a; 1 本题采用贪心思路&#xff0c;要使调整次数最少&#xff0c;就是尽量交换两个碱基对&#xff0c;而不是单个替换&#xff0c;因为本题已经说明只能每个碱基对只能交换一次&#xff0c;所以不考虑A与B交换再…