24届春招实习必备技能(一)之MyBatis Plus入门实践详解

MyBatis Plus入门实践详解

一、什么是MyBatis Plus?

MyBatis Plus简称MP,是mybatis的增强工具,旨在增强,不做改变。MyBatis Plus内置了内置通用 Mapper、通用 Service,仅仅通过少量配置即可实现单表大部分 CRUD 操作,更有强大的条件构造器,满足各类使用需求。

官网地址:https://mp.baomidou.com/

mp简介

主要特性

  • 无侵入:只做增强不做改变,引入它不会对现有工程产生影响,如丝般顺滑

  • 损耗小:启动即会自动注入基本 CURD(增加(Create)、读取(Read)、更新(Update)和删除(Delete)),性能基本无损耗,直接面向对象操作

  • 强大的 CRUD 操作:内置通用 Mapper、通用 Service,仅仅通过少量配置即可实现单表大部分 CRUD 操作,更有强大的条件构造器,满足各类使用需求

  • 支持 Lambda 形式调用:通过 Lambda 表达式,方便的编写各类查询条件,无需再担心字段写错

  • 支持主键自动生成:支持多达 4 种主键策略(内含分布式唯一 ID 生成器 - Sequence),可自由配置,完美解决主键问题

  • 支持 ActiveRecord 模式:支持 ActiveRecord 形式调用,实体类只需继承 Model 类即可进行强大的 CRUD 操作

  • 支持自定义全局通用操作:支持全局通用方法注入( Write once, use anywhere )

  • 内置代码生成器:采用代码或者 Maven 插件可快速生成 Mapper 、 Model 、 Service 、 Controller 层代码,支持模板引擎,更有超多自定义配置等您来使用

  • 内置分页插件:基于 MyBatis 物理分页,开发者无需关心具体操作,配置好插件之后,写分页等同于普通 List 查询

  • 分页插件支持多种数据库:支持 MySQL、MariaDB、Oracle、DB2、H2、HSQL、SQLite、Postgre、SQLServer 等多种数据库

  • 内置性能分析插件:可输出 Sql 语句以及其执行时间,建议开发测试时启用该功能,能快速揪出慢查询

  • 内置全局拦截插件:提供全表 delete 、 update 操作智能分析阻断,也可自定义拦截规则,预防误操作

框架结构

架构

二、MP的内置代码生成器

2.1 使用代码方式

这里使用springboot2.2.4.RELEASE,mybatis plus版本是3.1.2,添加MyBatis Plus对应maven依赖如下:

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

   <dependency>
       <groupId>com.baomidou</groupId>
       <artifactId>mybatis-plus-generator</artifactId>
       <version>3.3.0</version>
   </dependency>
    <dependency>
      <groupId>org.freemarker</groupId>
        <artifactId>freemarker</artifactId>
        <version>2.3.29</version>
    </dependency>

代码生成类如下:

public class CodeGenerator {

    /**
     * <p>
     * 读取控制台内容
     * </p>
     */
    public static String scanner(String tip) {
        Scanner scanner = new Scanner(System.in);
        StringBuilder help = new StringBuilder();
        help.append("请输入" + tip + ":");
        System.out.println(help.toString());
        if (scanner.hasNext()) {
            String ipt = scanner.next();
            if (StringUtils.isNotBlank(ipt)) {
                return ipt;
            }
        }
        throw new MybatisPlusException("请输入正确的" + tip + "!");
    }

    public static void main(String[] args) {
        // 代码生成器
        AutoGenerator mpg = new AutoGenerator();

        // 全局配置
        GlobalConfig gc = new GlobalConfig();
        String projectPath = System.getProperty("user.dir");
//        projectPath = projectPath+"/goods";
        gc.setOutputDir(projectPath + "/src/main/java");
        gc.setAuthor("gxm");
        gc.setOpen(false);
        // gc.setSwagger2(true); 实体属性 Swagger2 注解
        mpg.setGlobalConfig(gc);

        // 数据源配置
        DataSourceConfig dsc = new DataSourceConfig();
        dsc.setUrl("jdbc:mysql://localhost:3306/db_baby_shop?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8&useSSL=false");
        // dsc.setSchemaName("public");
        dsc.setDriverName("com.mysql.cj.jdbc.Driver");
        dsc.setUsername("root");
        dsc.setPassword("123456");
        mpg.setDataSource(dsc);

        // 包配置
        PackageConfig pc = new PackageConfig();
        pc.setModuleName(scanner("模块名"));
        pc.setParent("com.baby");
        mpg.setPackageInfo(pc);

        // 自定义配置
        InjectionConfig cfg = new InjectionConfig() {
            @Override
            public void initMap() {
                // to do nothing
            }
        };

        // 如果模板引擎是 freemarker
        String templatePath = "/templates/mapper.xml.ftl";
        // 如果模板引擎是 velocity
        // String templatePath = "/templates/mapper.xml.vm";

        // 自定义输出配置
        List<FileOutConfig> focList = new ArrayList<>();
        // 自定义配置会被优先输出
        String finalProjectPath = projectPath;
        focList.add(new FileOutConfig(templatePath) {
            @Override
            public String outputFile(TableInfo tableInfo) {
                // 自定义输出文件名 , 如果你 Entity 设置了前后缀、此处注意 xml 的名称会跟着发生变化!!
                return finalProjectPath + "/src/main/resources/mapper/" + pc.getModuleName()
                        + "/" + tableInfo.getEntityName() + "Mapper" + StringPool.DOT_XML;
            }
        });
        /*
        cfg.setFileCreate(new IFileCreate() {
            @Override
            public boolean isCreate(ConfigBuilder configBuilder, FileType fileType, String filePath) {
                // 判断自定义文件夹是否需要创建
                checkDir("调用默认方法创建的目录");
                return false;
            }
        });
        */
        cfg.setFileOutConfigList(focList);
        mpg.setCfg(cfg);

        // 配置模板
        TemplateConfig templateConfig = new TemplateConfig();

        // 配置自定义输出模板
        //指定自定义模板路径,注意不要带上.ftl/.vm, 会根据使用的模板引擎自动识别
        // templateConfig.setEntity("templates/entity2.java");
        // templateConfig.setService();
        // templateConfig.setController();

        templateConfig.setXml(null);
        mpg.setTemplate(templateConfig);

        // 策略配置
        StrategyConfig strategy = new StrategyConfig();
        strategy.setNaming(NamingStrategy.underline_to_camel);
        strategy.setColumnNaming(NamingStrategy.underline_to_camel);
//        strategy.setSuperEntityClass("com.manicure.goods.entity.BaseEntity");
        strategy.setEntityLombokModel(true);
        strategy.setRestControllerStyle(true);
        // 公共父类
//        strategy.setSuperControllerClass("com.manicure.goods.controller.common.BaseController");
        // 写于父类中的公共字段
        strategy.setSuperEntityColumns("id");
        strategy.setInclude(scanner("表名,多个英文逗号分割").split(","));
        strategy.setControllerMappingHyphenStyle(true);
        strategy.setTablePrefix(pc.getModuleName() + "_");
        mpg.setStrategy(strategy);
        mpg.setTemplateEngine(new FreemarkerTemplateEngine());
        mpg.execute();
    }

}

运行main方法,控制台输入模块名、表名即可:

img

2.2 使用maven插件方式

mybatisplus-maven-plugin插件官网:https://gitee.com/baomidou/mybatisplus-maven-plugin

官网插件

官网地址给了教程,需要先将插件安装到本地仓库mvn clean install,然后才能使用。这里给出一份pom文件如下:

 <plugin>
  <groupId>com.baomidou</groupId>
    <artifactId>mybatisplus-maven-plugin</artifactId>
    <version>1.0</version>
    <configuration>
        <!-- 输出目录(默认java.io.tmpdir) -->
        <outputDir>${project.basedir}/src/main/java</outputDir>
        <!-- 是否覆盖同名文件(默认false) -->
        <fileOverride>true</fileOverride>
        <!-- mapper.xml 中添加二级缓存配置(默认true) -->
        <enableCache>true</enableCache>

        <!-- 是否开启 ActiveRecord 模式(默认true) -->
        <activeRecord>false</activeRecord>
        <!-- 数据源配置,( **必配** ) -->
        <dataSource>
            <driverName>com.mysql.jdbc.Driver</driverName>
            <url>jdbc:mysql://127.0.0.1:3306/lab?serverTimezone=Asia/Shanghai</url>
            <username>root</username>
            <password>123456</password>
        </dataSource>
        <strategy>
            <!-- 字段生成策略,四种类型,从名称就能看出来含义:
                nochange(默认),
                underline_to_camel,(下划线转驼峰)
                remove_prefix,(去除第一个下划线的前部分,后面保持不变)
                remove_prefix_and_camel(去除第一个下划线的前部分,后面转驼峰) -->
            <naming>remove_prefix_and_camel</naming>
            <!-- 表前缀 -->
            <tablePrefix></tablePrefix>
            <!--Entity中的ID生成策略(默认 id_worker)-->
            <idGenType></idGenType>
            <!--自定义超类-->
            <!--<superServiceClass>com.baomidou.base.BaseService</superServiceClass>-->
            <!-- 要包含的表 与exclude 二选一配置-->
            <!--<include>-->
            <!--<property>sec_user</property>-->
            <!--<property>table1</property>-->
            <!--</include>-->
            <!-- 要排除的表 -->
            <!--<exclude>-->
            <!--<property>schema_version</property>-->
            <!--</exclude>-->
        </strategy>
        <packageInfo>
            <!-- 父级包名称,如果不写,下面的service等就需要写全包名(默认com.baomidou) -->
            <parent>com.jane</parent>
            <!--service包名(默认service)-->
            <service>service</service>
            <!--serviceImpl包名(默认service.impl)-->
            <serviceImpl>service.impl</serviceImpl>
            <!--entity包名(默认entity)-->
            <entity>entity</entity>
            <!--mapper包名(默认mapper)-->
            <mapper>mapper</mapper>
            <!--xml包名(默认mapper.xml)-->
            <xml>mapper.xml</xml>
        </packageInfo>
        <template>
            <!-- 定义controller模板的路径 -->
            <!--<controller>/template/controller1.java.vm</controller>-->
        </template>
    </configuration>
    <dependencies>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>8.0.13</version>
        </dependency>
    </dependencies>
</plugin>

然后如下图所示,执行命令即可:

mvn命令

三、传统SSM中使用MyBatis Plus

也就是说以前使用xml配置时(非SpringBoot)与MyBatis Plus整合。

3.1 引入依赖

如下是一些必要的依赖(你可以根据项目需要引入其他依赖):

<dependencies>
<!-- mp依赖
   mybatisPlus 会自动的维护Mybatis 以及MyBatis-spring相关的依赖
 -->
<dependency>
    <groupId>com.baomidou</groupId>
    <artifactId>mybatis-plus</artifactId>
    <version>2.3</version>
</dependency>   
<!--junit -->
<dependency>
  <groupId>junit</groupId>
  <artifactId>junit</artifactId>
  <version>4.9</version>
</dependency>
<!-- log4j -->
<dependency>
  <groupId>log4j</groupId>
  <artifactId>log4j</artifactId>
  <version>1.2.17</version>
</dependency>
<!-- c3p0 -->
<dependency>
  <groupId>com.mchange</groupId>
  <artifactId>c3p0</artifactId>
  <version>0.9.5.2</version>
</dependency>
<!-- mysql -->
<dependency>
  <groupId>mysql</groupId>
  <artifactId>mysql-connector-java</artifactId>
  <version>5.1.37</version>
</dependency>
<!-- spring -->
<dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-context</artifactId>
  <version>4.3.10.RELEASE</version>
</dependency>
<dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-orm</artifactId>
  <version>4.3.10.RELEASE</version>
</dependency>

</dependencies>

3.2 MP配置

applicationContext.xml中MP配置如下:

<!--  配置SqlSessionFactoryBean 
    Mybatis提供的: org.mybatis.spring.SqlSessionFactoryBean
    MP提供的:com.baomidou.mybatisplus.spring.MybatisSqlSessionFactoryBean
   -->
  <bean id="sqlSessionFactoryBean" class="com.baomidou.mybatisplus.spring.MybatisSqlSessionFactoryBean">
    <!-- 数据源 -->
    <property name="dataSource" ref="dataSource"></property>
    <property name="configLocation" value="classpath:mybatis-config.xml"></property>
    <!-- 别名处理 -->
    <property name="typeAliasesPackage" value="com.jane.mp.beans"></property>   
    <!-- 注入全局MP策略配置 -->
    <property name="globalConfig" ref="globalConfiguration"></property>
  </bean>
  
  <!-- 定义MybatisPlus的全局策略配置-->
  <bean id ="globalConfiguration" class="com.baomidou.mybatisplus.entity.GlobalConfiguration">
    <!-- 在2.3版本以后,dbColumnUnderline 默认值就是true -->
    <property name="dbColumnUnderline" value="true"></property>
    <!-- 全局的主键策略 -->
    <property name="idType" value="0"></property>
    <!-- 全局的表前缀策略配置 -->
    <property name="tablePrefix" value="tbl_"></property>
  </bean>

需要注意的是,这里sqlSessionFactoryBean从mybatis的org.mybatis.spring.SqlSessionFactoryBean换成了MyBatis Plus的com.baomidou.mybatisplus.spring.MybatisSqlSessionFactoryBean。

当然还有其他配置,比如mapper扫描器、mapperxml配置等,

四、SpringBoot整合MyBatis Plus

SpringBoot大大简化了开发配置,提高了开发效率。

4.1 引入依赖

MyBatis-Plus 从 3.0.3 之后移除了代码生成器与模板引擎的默认依赖,需要手动添加相关依赖。

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

  <dependency>
      <groupId>com.baomidou</groupId>
      <artifactId>mybatis-plus-generator</artifactId>
      <version>3.3.0</version>
  </dependency>
<!-- 代码生成器默认模板引擎是freemarker -->
 <dependency>
   <groupId>org.freemarker</groupId>
      <artifactId>freemarker</artifactId>
      <version>2.3.29</version>
 </dependency>

4.2 编写配置类

//Spring boot方式
@EnableTransactionManagement
@Configuration
@MapperScan("com.baomidou.cloud.service.*.mapper*")
public class MybatisPlusConfig {

    @Bean
    public PaginationInterceptor paginationInterceptor() {
        PaginationInterceptor paginationInterceptor = new PaginationInterceptor();
        // 设置请求的页面大于最大页后操作, true调回到首页,false 继续请求  默认false
        // paginationInterceptor.setOverflow(false);
        // 设置最大单页限制数量,默认 500 条,-1 不受限制
        // paginationInterceptor.setLimit(500);
        // 开启 count 的 join 优化,只针对部分 left join
        paginationInterceptor.setCountSqlParser(new JsqlParserCountOptimize(true));
        return paginationInterceptor;
    }
}

PaginationInterceptor 是MyBatis Plus的分页插件,同样有对应xml配置方式。如下可以在mybatis-config.xml里面注册:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
  <plugins>
    <plugin interceptor="com.baomidou.mybatisplus.plugins.PaginationInterceptor"></plugin>
  </plugins>

</configuration>

或者可以在applicationContext.xml中注册:

<!--  配置SqlSessionFactoryBean 
Mybatis提供的: org.mybatis.spring.SqlSessionFactoryBean
MP提供的:com.baomidou.mybatisplus.spring.MybatisSqlSessionFactoryBean
-->
<bean id="sqlSessionFactoryBean" class="com.baomidou.mybatisplus.spring.MybatisSqlSessionFactoryBean">
<!-- 数据源 -->
<property name="dataSource" ref="dataSource"></property>
<property name="configLocation" value="classpath:mybatis-config.xml"></property>
<!-- 别名处理 -->
<property name="typeAliasesPackage" value="com.atguigu.mp.beans"></property>    
<!-- 注入全局MP策略配置 -->
<property name="globalConfig" ref="globalConfiguration"></property>
<!-- 插件注册 -->
<property name="plugins">
  <list>
    <!-- 注册分页插件 -->
    <bean class="com.baomidou.mybatisplus.plugins.PaginationInterceptor"></bean>
    <!-- 注册执行分析插件 -->
    <bean class="com.baomidou.mybatisplus.plugins.SqlExplainInterceptor">
      <property name="stopProceed" value="true"></property>
    </bean>
    <!-- 注册性能分析插件 -->
    <bean class="com.baomidou.mybatisplus.plugins.PerformanceInterceptor">
      <property name="format" value="true"></property>
      <!-- <property name="maxTime" value="5"></property> -->
    </bean>
    <!-- 注册乐观锁插件 -->
    <bean class="com.baomidou.mybatisplus.plugins.OptimisticLockerInterceptor">
    </bean>
  </list>
</property>

</bean>

4.3 application.properties关于MP的配置

配置实例如下:

spring.datasource.url=jdbc:mysql://localhost:3306/db_baby_shop?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
spring.datasource.username=root
spring.datasource.password=123456
spring.datasource.driverClassName=com.mysql.jdbc.Driver

mybatis-plus.mapper-locations=classpath*:mapper/**/*.xml
mybatis-plus.type-aliases-package=com.jane.mapper

4.4 生成代码

使用代码生成类或者maven插件进行生成,具体参考4.2

五、主键策略与表及字段命名策略

5.1 主键策略选择

MP支持以下4中主键策略,可根据需求自行选用。

什么是Sequence?简单来说就是一个分布式高效有序ID生产黑科技工具,思路主要是来源于Twitter-Snowflake算法。MP在Sequence的基础上进行部分优化,用于产生全局唯一ID,ID_WORDER设置为默认配置。

5.2 表及字段命名策略选择

在MP中建议数据库表名 和 表字段名采用驼峰命名方式, 如果采用下划线命名方式 请开启全局下划线开关,如果表名字段名命名方式不一致请注解指定。

这么做的原因是为了避免在对应实体类时产生的性能损耗,这样字段不用做映射就能直接和实体类对应。当然如果项目里不用考虑这点性能损耗,那么你采用下滑线也是没问题的,只需要在生成代码时配置dbColumnUnderline属性就可以。

以前xml中可能配置如下:

<bean id ="globalConfiguration" class="com.baomidou.mybatisplus.entity.GlobalConfiguration">
  <!-- 在2.3版本以后,dbColumnUnderline 默认值就是true -->
  <property name="dbColumnUnderline" value="true"></property>
  <!-- 全局的主键策略 -->
  <property name="idType" value="0"></property>
  <!-- 全局的表前缀策略配置 -->
  <property name="tablePrefix" value="tbl_"></property>
</bean>

5.3 FieldStrategy 字段空值策略判断

如下枚举类所示,有三种策略:

public enum FieldStrategy {
    IGNORED(0, "忽略判断"),
    NOT_NULL(1, "非 NULL 判断"),
    NOT_EMPTY(2, "非空判断");
    //...
}    

解释说明如下:

IGNORED:不管有没有有设置属性,所有的字段都会设置到insert语句中,如果没设置值,全为null,这种在update 操作中会有风险,把有值的更新为null

NOT_NULL:也是默认策略,也就是忽略null的字段,不忽略""

NOT_EMPTY:为null,为空串的忽略,就是如果设置值为null,“”,不会插入数据库

六、MybatisX idea 快速开发插件

MybatisX 辅助 idea 快速开发插件,为效率而生。可以实现java 与 xml 跳转,根据 Mapper接口中的方法自动生成 xml结构

官方安装: File -> Settings -> Plugins -> Browse Repositories… 输入 mybatisx 安装下载

Jar 安装: File -> Settings -> Plugins -> Install plugin from disk… 选中 mybatisx…jar 点击下载安装

插件

安装完如下实例:

小鸟图案

七、自动生成的内容

其实这里是在MyBatis Plus通用CRUD与条件构造器使用及SQL自动注入原理分析后面补充的,主要是想说明service层。

如下图所示,MP的代码生成器可生成 : 实体类 (可以选择是否支持 AR)、 Mapper接口、 Mapper映射文件 、 Service层、 Controller层。

包结构图

其中mapper.xml类似如下包含一个返回结果字段属性映射与一个通用查询结果列。

<mapper namespace="com.jane.mapper.MaintainMapper">
  <!--开启二级缓存-->
  <cache type="org.mybatis.caches.ehcache.LoggingEhcache"/>

  <resultMap id="BaseResultMap" type="com.jane.entity.Maintain">
    <id column="id" property="id" />`在这里插入代码片`
    <result column="equip_id" property="equipId" />
    <result column="user_id" property="userId" />
    <result column="time" property="time" />
    <result column="content" property="content" />
  </resultMap>

    <!-- 通用查询结果列-->
    <sql id="Base_Column_List">
        id, equip_id AS equipId, user_id AS userId, time, content
    </sql>
</mapper>

不过这些不是我们的重点。在看过MyBatis Plus通用CRUD与条件构造器使用及SQL自动注入原理分析后我们知道了继承BaseMapper就能获取通用的CRUD方法。但是通常controller不会直接调用mapper接口的而是调用service。MP同样为我们考虑到了这一点,为我们生成了service与serviceImpl。

以IUserService为例我们看到其继承自IService,其实现类继承自ServiceImpl<UserMapper, User>并实现了IUserService接口。这样我们的UserServiceImpl就拥有了ServiceImpl提供的通用CRUD能力。

public interface IUserService extends IService<User> {
  
}
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IUserService {
  
}

那么ServiceImpl提供了哪些能力?如何提供的?

ServiceImpl源码如下:

/**/**
 * IService 实现类( 泛型:M 是 mapper 对象,T 是实体 , PK 是主键泛型 )
 *
 * @author hubin
 * @since 2018-06-23
 */
@SuppressWarnings("unchecked")
public class ServiceImpl<M extends BaseMapper<T>, T> implements IService<T> {

    protected Log log = LogFactory.getLog(getClass());

    @Autowired
    protected M baseMapper;

    @Override
    public M getBaseMapper() {
        return baseMapper;
    }
    //...
     public boolean save(T entity) {
        return retBool(baseMapper.insert(entity));
    }
    //...
  }

可以看到其主要是根据baseMapper来实现CRUD能力的,这就要要求你的mapper必须继承自BaseMapper。

八、SpringBoot整合Mybatis Plus常见配置

常见配置如下所示:

mybatis-plus:
  mapper-locations: classpath:/mapper/**/*Mapper.xml #mapper映射文件路径
  typeAliasesPackage: com.jane.**.domain #实体包扫描
  global-config:
    id-type: 2 #主键类型  全局唯一ID,内容为空自动填充(默认配置),对应数字 2
    field-strategy: 1 #字段策略 IGNORED-0:"忽略判断",NOT_NULL-1:"非 NULL 判断"),NOT_EMPTY-2:"非空判断"
    db-column-underline: true #表名、字段名、是否使用下划线命名
    capital-mode: false #是否大写命名
    sql-injector: com.baomidou.mybatisplus.mapper.LogicSqlInjector #逻辑删除注入器
    logic-not-delete-value: 0 #逻辑未删除值(默认为 0)
    logic-delete-value: 1 #逻辑已删除值(默认为 1)
  configuration:
    map-underscore-to-camel-case: true #下划线转驼峰
    cache-enabled: false # 是否开启缓存

写在最后

编程严选网(www.javaedge.cn),程序员的终身学习网站已上线!

如果这篇【文章】有帮助到你,希望可以给【JavaGPT】点个赞👍,创作不易,如果有对【后端技术】、【前端领域】感兴趣的小可爱,也欢迎关注❤️❤️❤️ 【JavaGPT】❤️❤️❤️,我将会给你带来巨大的【收获与惊喜】💝💝💝!

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

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

FileZilla的使用,主动模式和被动模式思维导图

注&#xff1a;图片 &#xff08;与上面的思维导图文字配图看&#xff09;

PAT乙级1045 快速排序

著名的快速排序算法里有一个经典的划分过程&#xff1a;我们通常采用某种方法取一个元素作为主元&#xff0c;通过交换&#xff0c;把比主元小的元素放到它的左边&#xff0c;比主元大的元素放到它的右边。 给定划分后的 N 个互不相同的正整数的排列&#xff0c;请问有多少个元…

node版本管理器nvm的下载和使用

介绍 nvm 全名 node.js version management&#xff0c;顾名思义是一个nodejs的版本管理工具。通过它可以安装和切换不同版本的nodejs。 下载和安装 在下载和安装nvm前&#xff0c;需要确保当前电脑没有安装node&#xff0c;否则则需要先把原来的node卸载了。 下载地址&#…

Oracle-深入了解cache buffer chain

文章目录 1.Cache buffer chain介绍2.Buffer cache的工作原理3 Buffer chains4.Multi-versioning of Buffers5.Latches6.诊断CBC latch等待7.解决 CBC Latch等待 1.Cache buffer chain介绍 经常看到会话等待事件“latch&#xff1a;cache buffers chain”。 如果想知道意味着什…

007、控制流

先看下本篇学习内容&#xff1a; 通过条件来执行 或 重复执行某些代码 是大部分编程语言的基础组成部分。在Rust中用来控制程序执行流的结构主要就是 if表达式 与 循环表达式。 1. if表达式 if表达式允许我们根据条件执行不同的代码分支。我们提供一个条件&#xff0c;并且做出…

Reac03:react脚手架配置(代理配置)

react脚手架配置 reactAjax下载Axios配置代理第二种配置代理的方式 github搜索案例 reactAjax React本身只关注于界面&#xff0c;并不包含发送ajax请求的代码前端应用需要通过ajax请求与后台进行交互(json数据)react应用中需要集成第三方ajax(或自己封装) 常用的ajax请求库 j…

ctfshow——文件上传

文章目录 文件上传思路web 151web 152web 153知识点解题 web 154web 155web 156web 157web 158web 159web160web 161 文件上传思路 web 151 打开页面显示&#xff1a;前台校验不可靠。说明这题是前端验证。 右键查看源代码&#xff0c;找到与上传点有关的前端代码&#xff1a…

[SSD 测试 1.3] 消费级SSD全生命周期测试

依公知及经验整理,原创保护,禁止转载。 专栏 《深入理解SSD》 <<<< 返回总目录 <<<< 构建消费级SSD全生命周期测试,开展性能测试、兼容性测试、功能测试、环境应力测试、可靠性测试、电器检测。 以忆联消费级存储实验室为例,消费级存储实验室面积…

docker应用部署(部署MySql,部署Tomcat,部署Nginx,部署Redis)

Docker 应用部署 一、部署MySQL 搜索mysql镜像 docker search mysql拉取mysql镜像 docker pull mysql:5.6创建容器&#xff0c;设置端口映射、目录映射 # 在/root目录下创建mysql目录用于存储mysql数据信息 mkdir ~/mysql cd ~/mysqldocker run -id \ -p 3307:3306 \ --na…

信号与线性系统翻转课堂笔记19——连续/离散系统的零极点与稳定性

信号与线性系统翻转课堂笔记19——连续/离散系统的零极点与稳定性 The Flipped Classroom19 of Signals and Linear Systems 对应教材&#xff1a;《信号与线性系统分析&#xff08;第五版&#xff09;》高等教育出版社&#xff0c;吴大正著 一、要点 &#xff08;1&#x…

中科亿海微UART协议

引言 在现代数字系统设计中&#xff0c;通信是一个至关重要的方面。而UART&#xff08;通用异步接收器/发送器&#xff09;协议作为一种常见的串行通信协议&#xff0c;被广泛应用于各种数字系统中。FPGA&#xff08;现场可编程门阵列&#xff09;作为一种灵活可编程的硬件平台…

2023结婚成家,2024借势起飞

您好&#xff0c;我是码农飞哥&#xff08;wei158556&#xff09;&#xff0c;感谢您阅读本文&#xff0c;欢迎一键三连哦。 &#x1f4aa;&#x1f3fb; 1. Python基础专栏&#xff0c;基础知识一网打尽&#xff0c;9.9元买不了吃亏&#xff0c;买不了上当。 Python从入门到精…

《深入理解JAVA虚拟机笔记》Java 运行时内存区域

程序计数器&#xff08;线程私有&#xff09; 程序计数器&#xff08;Program Counter Register&#xff09;是一块较小的内存空间&#xff0c;它可以看做是当前线程所执行的字节码的行号指示器。在 Java 虚拟机的概念模型里&#xff0c; 字节码解释器工作时就是通过改变这个计…

解决npm,pnpm,yarn等安装electron超时等问题

我在安装electron的时候&#xff0c;出现了超时等等各种问题&#xff1a; &#xff08;RequestError: connect ETIMEDOUT 20.205.243.166:443&#xff09; npm yarn&#xff1a;Request Error: connect ETIMEDOUT 20.205.243.166:443 RequestError: socket hang up npm ER…

2022年山东省职业院校技能大赛高职组云计算赛项试卷第二场-容器云

2022年山东省职业院校技能大赛高职组云计算赛项试卷 目录 【赛程名称】云计算赛项第二场-容器云 需要竞赛软件包以及资料可以私信博主&#xff01; 【赛程名称】云计算赛项第二场-容器云 【赛程时间】2022-11-27 09:00:00至2022-11-27 16:00:00 说明&#xff1a;完成本任务…

【揭秘】如何使用LinkedHashMap来实现一个LUR缓存?

LRU&#xff08;Least Recently Used&#xff09;缓存是一种常用的缓存淘汰策略&#xff0c;用于在有限的缓存空间中存储数据。其基本思想是&#xff1a;如果数据最近被访问过&#xff0c;那么在未来它被访问的概率也更高。因此&#xff0c;LRU缓存会保留最近访问过的数据&…

23种设计模式Python版

目录 创建型模式简单工厂模式工厂方法模式抽象工厂模式单例模式原型模式建造者模式 结构型模式适配器模式桥接模式组合模式装饰器模式外观模式享元模式代理模式 行为型模式职责链模式命令模式解释器模式迭代器模式中介者模式备忘录模式观察者模式状态模式策略模式模板方法模式访…

linux安装rabbitmq

文章目录 前言一、下载安装包二、erlang1.安装依赖2.解压3.安装4.环境变量5.验证 三、rabbitmq1.安装依赖2.解压3.新建目录4.rabbitmq.env.conf5.rabbitmq.conf6.环境变量7.启动8.验证9.停止 四、安装web1.安装插件2.访问控制台界面 五、开机启动1.编写脚本2.设置开机启动3.测试…

服务器的TCP连接限制:如何优化并提高服务器的并发连接数?

&#x1f308;&#x1f308;&#x1f308;&#x1f308;&#x1f308;&#x1f308;&#x1f308;&#x1f308; 欢迎关注公众号&#xff08;通过文章导读关注&#xff09;&#xff0c;发送【资料】可领取 深入理解 Redis 系列文章结合电商场景讲解 Redis 使用场景、中间件系列…

目标检测-One Stage-YOLOv1

文章目录 前言一、YOLOv1的网络结构和流程二、YOLOv1的损失函数三、YOLOv1的创新点总结 前言 前文目标检测-Two Stage-Mask RCNN提到了Two Stage算法的局限性&#xff1a; 速度上并不能满足实时的要求 因此出现了新的One Stage算法簇&#xff0c;YOLOv1是目标检测中One Stag…