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

MybatisPlus - 核心功能

文章目录

      • 1.MybatisPlus实现基本的CRUD
        • 快速开始
        • 常见注解
        • 常见配置
      • 2.使用条件构建造器构建查询和更新语句
        • 条件构造器
        • 自定义SQL
        • Service接口

在这里插入图片描述

官网
MybatisPlus无侵入和方便快捷.
MybatisPlus不仅仅可以简化单表操作,而且还对Mybatis的功能有很多的增强。可以让我们的开发更加的简单,高效。
通过今天的学习,我们要达成下面的目标:

  • 能利用MybatisPlus实现基本的CRUD
  • 会使用条件构建造器构建查询和更新语句

1.MybatisPlus实现基本的CRUD

快速开始

初始化工程: 配置文件

spring:datasource:url: jdbc:mysql://127.0.0.1:3306/mp?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&serverTimezone=Asia/Shanghaidriver-class-name: com.mysql.cj.jdbc.Driverusername: rootpassword: root
logging:level:com.itheima: debugpattern:dateformat: HH:mm:ss
mybatis:mapper-locations: classpath*:mapper/*.xml

实体类

@Data
public class User {/*** 用户id*/private Long id;/*** 用户名*/private String username;/*** 密码*/private String password;/*** 注册手机号*/private String phone;/*** 详细信息*/private String info;/*** 使用状态(1正常 2冻结)*/private Integer status;/*** 账户余额*/private Integer balance;/*** 创建时间*/private LocalDateTime createTime;/*** 更新时间*/private LocalDateTime updateTime;
}

dao层/mapper层

public interface UserMapper{void saveUser(User user);void deleteUser(Long id);void updateUser(User user);User queryUserById(@Param("id") Long id);List<User> queryUserByIds(@Param("ids") List<Long> ids);
}

mapper.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.itheima.mp.mapper.UserMapper"><insert id="saveUser" parameterType="com.itheima.mp.domain.po.User">INSERT INTO `user` (`id`, `username`, `password`, `phone`, `info`, `balance`)VALUES(#{id}, #{username}, #{password}, #{phone}, #{info}, #{balance});</insert><update id="updateUser" parameterType="com.itheima.mp.domain.po.User">UPDATE `user`<set><if test="username != null">`username`=#{username}</if><if test="password != null">`password`=#{password}</if><if test="phone != null">`phone`=#{phone}</if><if test="info != null">`info`=#{info}</if><if test="status != null">`status`=#{status}</if><if test="balance != null">`balance`=#{balance}</if></set>WHERE `id`=#{id};</update><delete id="deleteUser" parameterType="com.itheima.mp.domain.po.User">DELETE FROM user WHERE id = #{id}</delete><select id="queryUserById" resultType="com.itheima.mp.domain.po.User">SELECT *FROM userWHERE id = #{id}</select><select id="queryUserByIds" resultType="com.itheima.mp.domain.po.User">SELECT *FROM user<if test="ids != null">WHERE id IN<foreach collection="ids" open="(" close=")" item="id" separator=",">#{id}</foreach></if>LIMIT 10</select></mapper>

现在我们来改造!用mp快速体验一下:

<dependency><groupId>com.baomidou</groupId><artifactId>mybatis-plus-boot-starter</artifactId><version>3.5.3.1</version></dependency>

在这里插入图片描述

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itheima.mp.domain.po.User;
import org.apache.ibatis.annotations.Param;import java.util.List;public interface UserMapper extends BaseMapper<User> {
}

把那些方法全部都删除了,然后把mapper.xml文件也一并删除.我们继承的这个"爸爸"里面这些方法它都有,所以我们直接去测试类测试即可.

import com.itheima.mp.domain.po.User;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;import java.time.LocalDateTime;
import java.util.List;@SpringBootTest
class UserMapperTest {@Autowiredprivate UserMapper userMapper;@Testvoid testInsert() {User user = new User();user.setId(5L);user.setUsername("Lucy");user.setPassword("123");user.setPhone("18688990011");user.setBalance(200);user.setInfo("{\"age\": 24, \"intro\": \"英文老师\", \"gender\": \"female\"}");user.setCreateTime(LocalDateTime.now());user.setUpdateTime(LocalDateTime.now());userMapper.insert(user);}@Testvoid testSelectById() {User user = userMapper.selectById(5L);System.out.println("user = " + user);}@Testvoid testQueryByIds() {List<User> users = userMapper.selectBatchIds(List.of(1L, 2L, 3L, 4L));users.forEach(System.out::println);}@Testvoid testUpdateById() {User user = new User();user.setId(5L);user.setBalance(20000);userMapper.updateById(user);}@Testvoid testDeleteUser() {userMapper.deleteById(5L);}
}

全部都能测试成功,而且updateById语句如果你没有修改其他的字段那么其他字段不会修改.这样实现单表增删改查全部搞定.

常见注解

MybatisPlus通过扫描实体类,并基于反射获取实体类信息作为数据库表信息.
在这里插入图片描述
在这里插入图片描述

@Data
@TableName("user")
public class User {/*** 用户id*/@TableId(type = IdType.AUTO)//默认使用雪花算法生成idprivate Long id;/*** 用户名*/
//    @TableField("`username`")private String username;/*** 密码*/
//    @TableField(exist = false)private String password;/*** 注册手机号*/private String phone;/*** 详细信息*/private String info;/*** 使用状态(1正常 2冻结)*/private Integer status;/*** 账户余额*/private Integer balance;/*** 创建时间*/private LocalDateTime createTime;/*** 更新时间*/private LocalDateTime updateTime;
}
常见配置

在这里插入图片描述

但是其实大部分都是默认配置具体可以看官网那些是默认配置

在这里插入图片描述

mybatis-plus:type-aliases-package: com.itheima.mp.domain.poglobal-config:db-config:id-type: auto

2.使用条件构建造器构建查询和更新语句

核心功能:

条件构造器

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

  @Testvoid testQueryWrapper(){Wrapper<User> wrapper = new QueryWrapper<User>().select("id", "username", "info","balance").like("username", "o").ge("balance", 1000);List<User> users = userMapper.selectList(wrapper);users.forEach(System.out::println);}

debug信息:

14:40:41 DEBUG 26264 — [ main] c.i.mp.mapper.UserMapper.selectList : ==> Preparing: SELECT id,username,info,balance FROM user WHERE (username LIKE ? AND balance >= ?)
14:40:41 DEBUG 26264 — [ main] c.i.mp.mapper.UserMapper.selectList : > Parameters: %o%(String), 1000(Integer)
14:40:41 DEBUG 26264 — [ main] c.i.mp.mapper.UserMapper.selectList : <
Total: 1

  @Testvoid testUpdateWrapper(){//1.要更新的数据User user = new User();user.setBalance(2000);//2.更新的条件QueryWrapper<User> wrapper = new QueryWrapper<User>().eq("username", "jack");//3.执行更新userMapper.update(user,wrapper);}

debug日志信息:

14:45:32 DEBUG 15964 — [ main] com.itheima.mp.mapper.UserMapper.update : ==> Preparing: UPDATE user SET balance=? WHERE (username = ?)
14:45:32 DEBUG 15964 — [ main] com.itheima.mp.mapper.UserMapper.update : > Parameters: 2000(Integer), jack(String)
14:45:32 DEBUG 15964 — [ main] com.itheima.mp.mapper.UserMapper.update : <
Updates: 1

在这里插入图片描述

@Testvoid testUpdateWrapper(){UpdateWrapper<User> wrapper = new UpdateWrapper<User>().setSql("balance = balance + 200").in("id", List.of(1L, 2L, 3L, 4L));userMapper.update(null,wrapper);}

在这里插入图片描述
但是这种写法是硬编码.
推荐Lambda

 @Testvoid testLambdaQueryWrapper(){LambdaQueryWrapper<User> wrapper = new LambdaQueryWrapper<User>().select(User::getId, User::getUsername,User::getInfo, User::getBalance).like(User::getUsername, "o").ge(User::getBalance, 1000);List<User> users = userMapper.selectList(wrapper);users.forEach(System.out::println);}

在这里插入图片描述

自定义SQL

我们可以利用MybatisPlus的wrapper来构建where条件,然后自己定义SQL语句中剩下部分.
在这里插入图片描述
这样确实方便但是这是在业务层中,这在很多企业中是不允许的.
在这里插入图片描述
在这里插入图片描述

@Testvoid testCustomSql(){List<Long>ids = List.of(1L, 2L, 3L, 4L);int amount = 200;QueryWrapper<User> wrapper = new QueryWrapper<User>().in("id", ids);userMapper.updateBalanceByIds(wrapper, amount);}
public interface UserMapper extends BaseMapper<User> {@Update("UPDATE user set balance = balance + #{amount} ${ew.customSqlSegment}")void updateBalanceByIds(@Param(Constants.WRAPPER) QueryWrapper<User> wrapper, @Param("amount") int amount);
}
Service接口

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

@SpringBootTest
class IUserServiceTest {@Autowiredprivate IUserService userService;@Testvoid testSave(){User user = new User();
//        user.setId(5L);user.setUsername("yyy");user.setPassword("123");user.setPhone("18688990011");user.setBalance(200);user.setInfo("{\"age\": 24, \"intro\": \"英文老师\", \"gender\": \"female\"}");user.setCreateTime(LocalDateTime.now());user.setUpdateTime(LocalDateTime.now());userService.save(user);}@Testvoid testQuery(){List<User> users = userService.listByIds(List.of(1L, 2L, 3L));users.forEach(System.out::println);}}

我们发现Iservice 和 baseMapper其实有很多方法都是重复的,从功能上是一致的,那我们应该如何选择?这里给出一个案例来进行讲解:
在这里插入图片描述

<!--swagger-->
<dependency><groupId>com.github.xiaoymin</groupId><artifactId>knife4j-openapi2-spring-boot-starter</artifactId><version>4.1.0</version>
</dependency>
<!--web-->
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId>
</dependency>

然后配置swagger信息

knife4j:enable: trueopenapi:title: 用户管理接口文档description: "用户管理接口文档"email: zhanghuyi@itcast.cnconcat: 虎哥url: https://www.itcast.cnversion: v1.0.0group:default:group-name: defaultapi-rule: packageapi-rule-resources:- com.itheima.mp.controller
@Data
@ApiModel(description = "用户表单实体")
public class UserFormDTO {@ApiModelProperty("id")private Long id;@ApiModelProperty("用户名")private String username;@ApiModelProperty("密码")private String password;@ApiModelProperty("注册手机号")private String phone;@ApiModelProperty("详细信息,JSON风格")private String info;@ApiModelProperty("账户余额")private Integer balance;
}
@Data
@ApiModel(description = "用户VO实体")
public class UserVO {@ApiModelProperty("用户id")private Long id;@ApiModelProperty("用户名")private String username;@ApiModelProperty("详细信息")private String info;@ApiModelProperty("使用状态(1正常 2冻结)")private Integer status;@ApiModelProperty("账户余额")private Integer balance;
}

@Api(tags = "用户管理接口")
@RestController
@RequestMapping("/user")
@RequiredArgsConstructor
public class UserController {private final IUserService userService;// 注入userService 有final才注入//    public UserController(IUserService userService) {
//        this.userService = userService;
//    }@ApiOperation("新增用户接口")@PostMappingpublic void saveUser(@RequestBody UserFormDTO userDTO){//1.DTO拷贝1到POUser user = BeanUtil.copyProperties(userDTO, User.class);//2.新增userService.save(user);}@ApiOperation("删除用户接口")@DeleteMapping("/{id}")public void DeleteUser(@ApiParam(name = "id", value = "用户id", required = true) @PathVariable("id") Long id){userService.removeById(id);}@ApiOperation("根据id查询用户接口")@GetMapping("/{id}")public UserVO queryUser(@ApiParam(name = "id", value = "用户id", required = true) @PathVariable("id") Long id){User user = userService.getById(id);UserVO userVO = BeanUtil.copyProperties(user, UserVO.class);return userVO;}@ApiOperation("根据id批量查询用户接口")@PostMappingpublic List<UserVO> queryUser(@RequestParam("ids") List<Long> ids){List<User> users = userService.listByIds(ids);return BeanUtil.copyToList(users, UserVO.class);}}

以后在大多数场景下直接用IService就可以了,因为这几个没有业务逻辑。
第五个接口是有业务的接口,要判断状态,判断余额数量等等。。
在controller中

@ApiOperation("扣减用户余额接口")@PutMapping("/{id}/deduction/{money}")public void deduction(@ApiParam(name = "id", value = "用户id", required = true) @PathVariable("id") Long id,@ApiParam(name = "money", value = "扣减金额", required = true) @PathVariable("money") Integer money) {userService.deduction(id, money);}

service层

public interface IUserService extends IService<User> {void deduction(Long id, Integer money);
}

serviceImpl

@Service
public class UserServiceImlp extends ServiceImpl<UserMapper, User> implements IUserService  {@Overridepublic void deduction(Long id, Integer money) {//1. 根据id查询用户User user = this.getById(id);//2.检验用户状态if(user==null || user.getStatus()!=1){throw new RuntimeException("用户状态异常");}//3.检验余额是否充足if(user.getBalance()<money){throw new RuntimeException("余额不足");}//4.扣除余额baseMapper.deductBalance(id,money);}
}

mapper:

public interface UserMapper extends BaseMapper<User> {@Update("UPDATE user set balance = balance + #{amount} ${ew.customSqlSegment}")void updateBalanceByIds(@Param(Constants.WRAPPER) QueryWrapper<User> wrapper, @Param("amount") int amount);@Update("UPDATE user set balance = balance - #{money} WHERE id = #{id}")void deductBalance(@Param("id") Long id,@Param("money") Integer money);
}
import cn.hutool.core.bean.BeanUtil;
import com.itheima.mp.domain.dto.UserFormDTO;
import com.itheima.mp.domain.po.User;
import com.itheima.mp.domain.vo.UserVO;
import com.itheima.mp.service.IUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;import java.util.List;@Api(tags = "用户管理接口")
@RestController
@RequestMapping("/user")
@RequiredArgsConstructor
public class UserController {private final IUserService userService;// 注入userService 有final才注入//    public UserController(IUserService userService) {
//        this.userService = userService;
//    }@ApiOperation("新增用户接口")@PostMappingpublic void saveUser(@RequestBody UserFormDTO userDTO){//1.DTO拷贝1到POUser user = BeanUtil.copyProperties(userDTO, User.class);//2.新增userService.save(user);}@ApiOperation("删除用户接口")@DeleteMapping("/{id}")public void DeleteUser(@ApiParam(name = "id", value = "用户id", required = true) @PathVariable("id") Long id){userService.removeById(id);}@ApiOperation("根据id查询用户接口")@GetMapping("/{id}")public UserVO queryUser(@ApiParam(name = "id", value = "用户id", required = true) @PathVariable("id") Long id){User user = userService.getById(id);UserVO userVO = BeanUtil.copyProperties(user, UserVO.class);return userVO;}@ApiOperation("根据id批量查询用户接口")@PostMappingpublic List<UserVO> queryUser(@RequestParam("ids") List<Long> ids){List<User> users = userService.listByIds(ids);return BeanUtil.copyToList(users, UserVO.class);}@ApiOperation("扣减用户余额接口")@PutMapping("/{id}/deduction/{money}")public void deduction(@ApiParam(name = "id", value = "用户id", required = true) @PathVariable("id") Long id,@ApiParam(name = "money", value = "扣减金额", required = true) @PathVariable("money") Integer money) {userService.deduction(id, money);}}

在这里插入图片描述
query:

@Data
@ApiModel(description = "用户查询条件实体")
public class UserQuery {@ApiModelProperty("用户名关键字")private String name;@ApiModelProperty("用户状态:1-正常,2-冻结")private Integer status;@ApiModelProperty("余额最小值")private Integer minBalance;@ApiModelProperty("余额最大值")private Integer maxBalance;
}

controller:

@ApiOperation("根据复杂条件查询用户接口")@GetMapping("/list")public List<UserVO> queryUserByCondition(UserQuery query){List<User>users = userService.queryUsers(query.getName(),query.getStatus(),query.getMinBalance(),query.getMaxBalance())return BeanUtil.copyToList(users, UserVO.class);}

IUservice:

public interface IUserService extends IService<User> {void deduction(Long id, Integer money);List<User> queryUsers(String name, Integer status, Integer minBalance, Integer maxBalance);
}

serviceimpl

public List<User> queryUsers(String name, Integer status, Integer minBalance, Integer maxBalance) {return  lambdaQuery().like(name != null, User::getUsername, name).eq(status != null, User::getStatus, status).ge(minBalance != null, User::getBalance, minBalance).le(name != null, User::getBalance, maxBalance).list();}

在这里插入图片描述

@Service
public class UserServiceImlp extends ServiceImpl<UserMapper, User> implements IUserService  {@Transactionalpublic void deduction(Long id, Integer money) {//1. 根据id查询用户User user = this.getById(id);//2.检验用户状态if(user==null || user.getStatus()!=1){throw new RuntimeException("用户状态异常");}//3.检验余额是否充足if(user.getBalance()<money){throw new RuntimeException("余额不足");}//4.扣除余额
//        baseMapper.deductBalance(id,money);int remainBalance = user.getBalance()-money;//乐观锁 compare and setlambdaUpdate().set(User::getBalance,remainBalance).set(remainBalance==0,User::getStatus,2).eq(User::getId,id).eq(User::getBalance,user.getBalance()) //乐观锁 让并发安全性更好.update();//不要忘记这一条}
}

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
上面哪一种一条条执行,每一次提交都是一次网络请求,每次网络请求都要耗费一定的时间,而下面每次插入1000条,采取预编译方案,相当于每1000次才发一次网络请求
在这里插入图片描述
如何把我们的sql语句变成这样?用动态SQL,foreach,或者还是使用mp的批处理指令,但是你会发现这个sql语句不对啊,但其实这个不对只是缺少了一个参数rewriteBatchedStatements=true参数,这个配置是mysql的配置,默认为false所以我们之前以为的批处理实际上都是一条条的插入,所以我们要改这个配置

spring:datasource:url: jdbc:mysql://127.0.0.1:3306/mp?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=truedriver-class-name: com.mysql.cj.jdbc.Driverusername: rootpassword: root

在url后面加上这个参数即可

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

相关文章:

MybatisPlus - 核心功能

文章目录 1.MybatisPlus实现基本的CRUD快速开始常见注解常见配置 2.使用条件构建造器构建查询和更新语句条件构造器自定义SQLService接口 官网 MybatisPlus无侵入和方便快捷. MybatisPlus不仅仅可以简化单表操作&#xff0c;而且还对Mybatis的功能有很多的增强。可以让我们的开…...

小柴冲刺软考中级嵌入式系统设计师系列二、嵌入式系统硬件基础知识(6)嵌入式系统总线及通信接口

目录 越努力&#xff0c;越幸运&#xff01; flechazo 小柴冲刺软考中级嵌入式系统设计师系列总目录 一、PCI、PCI-E 等接口基本原理与结构 1、PCI (1)高速性。 (2)即插即用性。 (3)可靠性。 (4)复杂性。 (5)自动配置。 (6)共享中断。 (7)扩展性好。 (8)多路复用。…...

利用字典对归一化后的数据0误差还原

假设我对精度要求很高&#xff0c;高到无法容忍有任何误差&#xff0c;那么我先将x按照大小排序&#xff0c;然后归一化&#xff0c;用字典将归一化前后的x存储下来&#xff0c;在深度学习时使用归一化后的x进行处理&#xff0c;但是最后画图等处理时&#xff0c;我用字典取出归…...

HarmonyOS:UIAbility组件概述

一、概述 UIAbility组件是一种包含UI的应用组件&#xff0c;主要用于和用户交互。 UIAbility的设计理念&#xff1a; 原生支持应用组件级的跨端迁移和多端协同。支持多设备和多窗口形态。 UIAbility划分原则与建议&#xff1a; UIAbility组件是系统调度的基本单元&#xff0c…...

12寸半导体厂说的华夫区是什么意思

1\什么是华夫板 在半导体行业中,“华夫区”通常指的是“华夫板”(Waffle Slab),这是一种特殊设计的楼板,其表面具有许多均匀分布的孔洞,这些孔洞形成了回风通道,用于电子芯片厂房等对空气洁净度有极高要求的环境。华夫板的设计和施工对于保证洁净室的功能发挥至关重要。…...

数据结构之链式结构二叉树的实现(进阶版)

本篇文章主要讲解链式二叉树的层序遍历以及判断是否为一棵完全二叉树 二者将会用到之前学过的队列知识&#xff0c;是将队列和二叉树的整合 一、如何将之前已经写好的文件加入当前的编译界面 如图所示&#xff0c;打开我们需要加入文件所在的文件夹&#xff0c;找到我们要加…...

【高等数学】3-2多元函数积分学

1. 二重积分 可以想象你有一块不规则的平面薄板,它在一个平面区域上。二重积分就是用来求这个薄板的质量(假设薄板的面密度函数是)。 把区域划分成许多非常小的小方块(类似于把一块地划分成很多小格子),在每个小方块上,密度近似看成是一个常数,然后把每个小方块的质量加…...

【传知代码】智慧医疗:纹理特征VS卷积特征

&#x1f351;个人主页&#xff1a;Jupiter. &#x1f680; 所属专栏&#xff1a;传知代码 欢迎大家点赞收藏评论&#x1f60a; 目录 论文概述纹理特征和深度卷积特征算法流程数据预处理方法纹理特征提取深度卷积特征提取分类网络搭建代码复现BLS_Model.py文件——分类器搭建py…...

Python-创建并调用自定义文件中的模块/函数

背景&#xff1a;在Python编程中&#xff0c;我们常常需要创建自己的专属文件&#xff0c;以便帮助我们更高效&#xff0c;快捷地完成任务。那么在Python中我们怎么创建并调用自己文件中的模块/函数呢? 在Python中调用自定义文件&#xff0c;通常是指调用自己编写的Python模块…...

Kali Linux

起源与背景 Kali Linux是一个基于Debian的开源Linux发行版&#xff0c;专门为信息安全工作者和渗透测试员设计。它是由Offensive Security Ltd.开发和维护的&#xff0c;作为BackTrack的继承者而诞生。BackTrack是一个流行的安全测试发行版&#xff0c;但为了提供更好的支持和…...

DiffusionDet: Diffusion Model for Object Detection—用于对象检测的扩散模型论文解析

DiffusionDet: Diffusion Model for Object Detection—用于对象检测的扩散模型论文解析 这是一篇发表在CVPR 2023的一篇论文&#xff0c;因为自己本身的研究方向是目标跟踪&#xff0c;之前看了一点使用扩散模型进行多跟踪的论文&#xff0c;里面提到了DiffusionDet因此学习一…...

深度学习基础知识-编解码结构理论超详细讲解

编解码结构&#xff08;Encoder-Decoder&#xff09;是一种应用广泛且高效的神经网络架构&#xff0c;最早用于序列到序列&#xff08;Seq2Seq&#xff09;任务&#xff0c;如机器翻译、图像生成、文本生成等。随着深度学习的发展&#xff0c;编解码结构不断演变出多种模型变体…...

探讨Java深搜算法的学习笔记

大家好&#xff0c;我是 V 哥。深度优先搜索&#xff08;DFS&#xff09;是一种图遍历算法&#xff0c;它优先深入到某条路径的尽头&#xff0c;再回溯到前一个节点继续探索其他路径&#xff0c;直到找到目标或遍历完整个图。DFS的应用场景广泛&#xff0c;可以用于路径搜索、连…...

408——操作系统(持续更新)

文章目录 一、操作系统的概念及特征1.1 计算机系统的概念1.2 操作系统的基本特征 二、操作系统的功能和接口2.1 操作系统作为计算机资源的管理者2.2 操作系统作为用户和计算机硬件系统之间的接口2.3 操作系统实现对计算机资源的扩充 三、操作系统的发展和分类四、操作系统的运行…...

架构师之路-学渣到学霸历程-37

Nginx的热部署实验 本次分享的就是nginx的升级以及降级&#xff0c;实验中其实很多操作都需要理解&#xff0c;实际操作不难&#xff0c;但是需要全面理解这个动作&#xff0c;敲这个命令是用来干什么的&#xff1f;借着这个笔记可以试一下&#xff1b;go~&#xff01; 1、ng…...

CSRF与SSRF

csrf(跨站请求伪造)的原理: csrf全称是跨站请求伪造(cross-site request forgery)&#xff0c;也被称为one-click attack 或者 session riding scrf攻击利用网站对于用户网页浏览器的信任&#xff0c;劫持用户当前已登录的web应用程序&#xff0c;去执行分用户本意的操作。 利…...

RabbitMQ 存储机制

一、消息存储机制 不管是持久化的消息还是非持久化的消息都可以被写入到磁盘。持久化的消息在到达队列时就被写入到磁盘&#xff0c;非持久化的消息一般只保存在内存中&#xff0c;在内存吃紧的时候会被换入到磁盘中&#xff0c;以节省内存空间。这两种类型的消息的落盘处理都…...

【Java SE】类型转换

类型转换是将一个值从一种类型转换为另一种类型的过程。该过程如果从低精度数据类型转为高精度数据类型&#xff0c;则不会发生溢出并且总能成功&#xff0c;如果从高精度数据类型转为低精度数据类型&#xff0c;则会有信息丢失且可能失败。类型转换又可分为隐式转换和显式转换…...

JAVA:常见 JSON 库的技术详解

1、简述 在现代应用开发中&#xff0c;JSON&#xff08;JavaScript Object Notation&#xff09;已成为数据交换的标准格式。Java 提供了多种方式将对象转换为 JSON 或从 JSON 转换为对象&#xff0c;常见的库包括 Jackson、Gson 和 org.json。本文将介绍几种常用的 JSON 处理…...

Redis缓存击穿、雪崩、穿透解决方案

Redis 缓存击穿、雪崩、穿透解决方案 1、首先看看逻辑方面是否还有优化空间&#xff0c;正常流程查询redis中获取不到数据&#xff0c;则去数据库获取&#xff0c;但数据库查询并返回时&#xff0c;调用异步方法&#xff0c;将该数据存储进redis中&#xff0c;并设置一个较短的…...

C++ 优先算法——盛最多水的容器(双指针)

目录 题目&#xff1a;盛最多水的容器 1. 题目解析 2. 算法原理 3. 代码实现 题目&#xff1a;盛最多水的容器 1. 题目解析 题目截图: 如图所示&#xff1a; 水的高度一定是由较低的那条线的高度决定的&#xff1a;例1图中&#xff0c;是由7决定的&#xff0c;然后求出…...

blender 小车建模 建模 学习笔记

一、学习blender视频教程链接 案例4&#xff1a;狂奔的小车_建模_哔哩哔哩_bilibilihttps://www.bilibili.com/video/BV1Bt4y1E7qn?p14&spm_id_from333.788.videopod.episodes&vd_sourced0ea58f1127eed138a4ba5421c577eb1 二、开始建模 &#xff08;1&#xff09;创…...

导出列表数据到Excel并下载

Java导出查询到的数据列表为Excel并下载 1.背景 工作中经常有需求&#xff0c;需要把列表的数据导出为Excel并下载。EasyExcel工具可以很好的实现这一需求。 2.实现流程 1.引入EasyExcel依赖包 <dependency><groupId>com.alibaba</groupId><artifactId…...

基于NVIDIA NIM平台实现盲人过马路的demo(一)

前言:利用NVIDIA NIM平台提供的大模型进行编辑,通过llama-3.2-90b-vision-instruct模型进行初步的图片检测 step1: 部署大模型到本地,引用所需要的库 import os import requests import base64 import cv2 import time from datetime import datetimestep2: 观看官方使用文…...

美格智能5G车规级通信模组:以连接+算力驱动智能化进阶

2023年3月&#xff0c;基于高通公司第二代骁龙汽车5G调制解调器及射频系统平台SA522M/SA525M&#xff0c;美格智能在德国纽伦堡嵌入式系统展上正式发布全新一代5G车规级C-V2X通信模组MA922系列&#xff0c;迅速引起行业和市场关注。随着5G高速网联逐步成为智能汽车标配&#xf…...

[MRCTF2020]PYWebsite1

如果输入的密钥是对的那么我们就直接跳转到flag.php页面 那么我们直接访问&#x1f60e;&#xff0c;他不带我们去我们自己去. 那就用XFF呗. 知识点&#xff1a; 定义&#xff1a;X-Forwarded-For是一个HTTP请求头字段&#xff0c;用于识别通过HTTP代理或负载均衡方式连接到W…...

无源元器件-磁珠选型参数总结

🏡《总目录》 目录 1,概述2,磁珠选型参数2.1,电学参数2.1.3,阻抗(Impedance)2.1.2,额定电流(Rated Current)2.1.3,直流电阻(DC Resistance)2.2,机械性能参数2.2.1,外观和尺寸(Appearance and Dimensions)2.2.2,粘接强度( Bonding Strength)2.2.3,弯曲强度…...

宝顶白芽,慢生活的味觉盛宴

在快节奏的生活中&#xff0c;人们愈发向往那种悠然自得、返璞归真的生活方式。白茶&#xff0c;以其独特的韵味和清雅的风格&#xff0c;成为了现代人追求心灵宁静与生活品质的象征。而在众多白茶之中&#xff0c;竹叶青茶业出品的宝顶白芽以其甘甜醇爽的特质&#xff0c;成为…...

已知三角形三边长求面积用仓颉语言作答

仓颉语言 https://cangjie-lang.cn/ linux和win和mac均有sdk&#xff0c;在本机deepinlinuxv23下载到本地解压缩到目录下设置环境变量 source envsetup.sh 比java方便太多了&#xff0c;java每次都是要自己搞很久&#xff0c;当然&#xff0c;打开看一下envsertup.sh,和我们…...

【JavaScript】匿名函数及回调函数总结

JavaScript 匿名函数 匿名函数没有显式的名称, 被视为一个函数表达式&#xff0c;可以在不需要额外命名的情况下进行定义和使用, 通常被用作回调函数, 即将函数作为参数传递给其他函数。 回调函数是在特定事件或条件发生时被调用的函数&#xff0c;回调函数通常用于异步编程中…...