MyBatis-Plus Generator v2.0.8 ~ v3.1.1 最新代码自动生成器

news2024/10/3 0:21:38

一、概述

官网:https://baomidou.com/

官方文档 :https://baomidou.com/pages/56bac0/

官方源码地址: https://gitee.com/baomidou/mybatis-plus

官方原话:

AutoGenerator 是 MyBatis-Plus 的代码生成器,通过 AutoGenerator 可以快速生成
Entity、Mapper、Mapper XML、Service、Controller 等各个模块的代码,极大的提升了开发效率。

配置环境

  • 开发工具 IDEA
  • JDK 8 +
  • 数据库 Mysql 、Oracle …
  • 基于SpringBoot开发框架

特性

  • 无侵入:Mybatis-Plus 在 Mybatis 的基础上进行扩展,只做增强不做改变,引入 Mybatis-Plus 不会对现有的 Mybatis 构架产生任何影响,而且 MP 支持所有 Mybatis 原生的特性
  • 依赖少:仅仅依赖 Mybatis 以及 Mybatis-Spring
  • 损耗小:启动即会自动注入基本CURD,性能基本无损耗,直接面向对象操作
  • 预防Sql注入:内置Sql注入剥离器,有效预防Sql注入攻击
  • 通用CRUD操作:内置通用 Mapper、通用 Service,仅仅通过少量配置即可实现单表大部分 CRUD 操作,更有强大的条件构造器,满足各类使用需求
  • 多种主键策略:支持多达4种主键策略(内含分布式唯一ID生成器),可自由配置,完美解决主键问题
  • 支持ActiveRecord:支持 ActiveRecord 形式调用,实体类只需继承 Model 类即可实现基本 CRUD 操作
  • 支持代码生成:采用代码或者 Maven 插件可快速生成 Mapper 、 Entity、 Service 、 Controller 层代码,支持模板引擎,更有超多自定义配置等您来使用(P.S. 比 Mybatis 官方的 Generator 更加强大!)
  • 支持自定义全局通用操作:支持全局通用方法注入( Write once, use anywhere )
  • 支持关键词自动转义:支持数据库关键词(order、key……)自动转义,还可自定义关键词
  • 内置分页插件:基于Mybatis物理分页,开发者无需关心具体操作,配置好插件之后,写分页等同于普通List查询
  • 内置性能分析插件:可输出Sql语句以及其执行时间,建议开发测试时启用该功能,能有效解决慢查询
  • 内置全局拦截插件:提供全表 delete 、 update 操作智能分析阻断,预防误操作

二、配置说明

2.1 、基本配置

属性类型说明
dataSourceDataSourceConfig数据源配置,通过该配置,指定需要生成代码的具体数据库,具体请查看 数据源配置
strategyStrategyConfig数据库表配置,通过该配置,可指定需要生成哪些表或者排除哪些表,具体请查看 数据库表配置
packageInfoPackageConfig包名配置,通过该配置,指定生成代码的包路径,具体请查看 包名配置
templateTemplateConfig模板配置,可自定义代码生成的模板,实现个性化操作,具体请查看 模板配置
globalConfigGlobalConfig全局策略配置,具体请查看 全局策略配置
injectionConfigInjectionConfig注入配置,通过该配置,可注入自定义参数等操作以实现个性化操作,具体请查看 注入配置

2.2 数据库配置(DataSourceConfig)

可选配置

方法说明示例 / 参数
dbQuery(IDbQuery)数据库查询new MySqlQuery()
schema(String)数据库schema(部分数据库适用) mybatis-plus
typeConvert(ITypeConvert)数据库类型转换器new MySqlTypeConvert()
dbType数据库类型,该类内置了常用的数据库类型【必须】DbType.MYSQL
driverName驱动名称com.mysql.jdbc.Driver
urljdbc路径jdbc:mysql://localhost:3306/(数据库名称)
username数据库账号root
password数据库密码123456
		Properties props = getProperties();
		DataSourceConfig dsc = new DataSourceConfig();
		dsc.setDbType(DbType.MYSQL);
		dsc.setTypeConvert(new MySqlTypeConvert());
		dsc.setDriverName("com.mysql.jdbc.Driver");
		dsc.setUsername(props.getProperty("db.master.user"));
		dsc.setPassword(props.getProperty("db.master.password"));
		dsc.setUrl(props.getProperty("db.master.url"));
		mpg.setDataSource(dsc);

2.3 全局配置(GlobalConfig)

方法说明示例 / 参数
outputDir生成文件的输出目录默认值:D 盘根目录
fileOverride是否覆盖已有文件默认值:false
open是否打开输出目录默认值:true
enableCache是否在 xml 中添加二级缓存配置默认值:`false
author开发人员默认值:null
kotlin开启 Kotlin 模式默认值:false
swagger2开启 swagger2 模式默认值:false
activeRecord开启 ActiveRecord 模式默认值:false
baseResultMap开启 BaseResultMap默认值:false
baseColumnList开启 baseColumnList默认值:false
dateType时间类型对应策略默认值:TIME_PACK 注意事项: 如下配置 %s 为占位符
entityName实体命名方式默认值:null 例如:%sEntity 生成 UserEntity
mapperNamemapper 命名方式默认值:null 例如:%sDao 生成 UserDao
xmlNameMapper xml 命名方式默认值:null 例如:%sDao 生成 UserDao.xml
serviceNameservice 命名方式默认值:null 例如:%sBusiness 生成 UserBusiness
serviceImplNameservice impl 命名方式默认值:null 例如:%sBusinessImpl 生成 UserBusinessImpl
controllerNamecontroller 命名方式默认值:null 例如:%sAction 生成 UserAction
idType指定生成的主键的 ID 类型默认值:null
		// 全局配置
		GlobalConfig gc = new GlobalConfig();
		gc.setOutputDir(outputDir);
		gc.setFileOverride(true);
		gc.setActiveRecord(true);// 开启 activeRecord 模式
		gc.setEnableCache(false);// XML 二级缓存
		gc.setBaseResultMap(true);// XML ResultMap
		gc.setBaseColumnList(false);// XML columList
		gc.setAuthor("zhixuan.wang");

		// 自定义文件命名,注意 %s 会自动填充表实体属性!
		gc.setMapperName("%sMapper");
		gc.setXmlName("%sMapper");
		gc.setServiceName("I%sService");
		gc.setServiceImplName("%sServiceImpl");
		gc.setControllerName("%sController");
		mpg.setGlobalConfig(gc);

2.4 包配置(PackageConfig)

方法说明示例 / 参数
parent(String)父包名。如果为空,将下面子包名必须写全部, 否则就只需写子包名
moduleName(String)父包模块名默认值:无
entity(String)实体类 Entity 包名默认值:entity
service(String)Service 包名默认值:service
serviceImpl(String)实现类 Service Impl 包名默认值:service.impl
mapper(String)Mapper 包名默认值:mapper
xmlMapper XML 包名默认值:mapper.xml
controllerController 包名默认值:controller
pathInfo(Map<OutputFile, String>)路径配置信息Collections.singletonMap(OutputFile.mapperXml, “D://”)
		// 包配置
		PackageConfig pc = new PackageConfig();
		pc.setModuleName(null);  //所属模块
		pc.setParent("com.wangzhixuan"); // 自定义包路径
		pc.setController("controller"); // 这里是控制器包名,默认 web
		pc.setEntity("model");
		pc.setXml("sqlMapperXml");
		mpg.setPackageInfo(pc);

2.5 模板配置(TemplateConfig)

方法说明示例 / 参数
entity(String)设置实体模板路径(JAVA)/templates/entity.java
entityKt(String)设置实体模板路径(kotlin)/templates/entity.java
service(String)设置 service 模板路径/templates/service.java
serviceImpl(String)设置 serviceImpl 模板路径/templates/serviceImpl.java
mapper(String)设置 mapper 模板路径/templates/mapper.java
xml(String)设置 mapperXml 模板路径/templates/mapper.xml
controller(String)设置 controller 模板路径/templates/controller.java
		//初始化模板配置
		TemplateConfig templateConfig = new TemplateConfig();
		templateConfig.setController("/templates/controller.java.vm");
		templateConfig.setEntity("/templates/controller.java.vm");
		templateConfig.setXml("/templates/sqlMapperXml.xml.vm");
		templateConfig.setMapper("/templates/mapper.java.vm");
		templateConfig.setService("/templates/service.java.vm");
		templateConfig.setServiceImpl("/templates/serviceImpl.java.vm");
		

MyBatis-Plus 原生默认模板:

在这里插入图片描述

2.6 注入配置(InjectionConfig)

方法说明示例 / 参数
map自定义返回配置 Map 对象该对象可以传递到模板引擎通过 cfg.xxx 引用
fileOutConfigList自定义输出文件配置 FileOutConfig 指定模板文件、输出文件达到自定义文件生成目的
fileCreate自定义判断是否创建文件 实现 IFileCreate 接口该配置用于判断某个类是否需要覆盖创建,当然你可以自己实现差异算法 merge 文件
initMap注入自定义 Map 对象(注意需要 setMap 放进去)
		// 注入自定义配置,可以在 VM 中使用 cfg.abc 设置的值
		InjectionConfig cfg = new InjectionConfig() {
			@Override
			public void initMap() {}
		};
		// 生成的模版路径,不存在时需要先新建
		File viewDir = new File(viewOutputDir);
		if (!viewDir.exists()) {
			viewDir.mkdirs();
		}
		List<FileOutConfig> focList = new ArrayList<FileOutConfig>();
		focList.add(new FileOutConfig("/templates/add.jsp.vm") {
			@Override
			public String outputFile(TableInfo tableInfo) {
				return getGeneratorViewPath(viewOutputDir, tableInfo, "Add.jsp");
			}
		});
		focList.add(new FileOutConfig("/templates/edit.jsp.vm") {
			@Override
			public String outputFile(TableInfo tableInfo) {
				return getGeneratorViewPath(viewOutputDir, tableInfo, "Edit.jsp");
			}
		});
		focList.add(new FileOutConfig("/templates/list.jsp.vm") {
			@Override
			public String outputFile(TableInfo tableInfo) {
				return getGeneratorViewPath(viewOutputDir, tableInfo, "List.jsp");
			}
		});
		cfg.setFileOutConfigList(focList);
		mpg.setCfg(cfg);
		

在这里插入图片描述

2.7 策略配置(StrategyConfig)

方法说明示例 / 参数
isCapitalMode是否大写命名
skipView是否跳过视图
naming数据库表映射到实体的命名策略
columnNaming数据库表字段映射到实体的命名策略, 未指定按照 naming 执行
tablePrefix表前缀
fieldPrefix字段前缀
superEntityClass自定义继承的 Entity 类全称,带包名
superEntityColumns自定义基础的 Entity 类,公共字段
superMapperClass自定义继承的 Mapper 类全称,带包名
superServiceClass自定义继承的 Service 类全称,带包名
superServiceImplClass自定义继承的 ServiceImpl 类全称,带包名
superControllerClass自定义继承的 Controller 类全称,带包名
enableSqlFilter(since 3.3.1)默认激活进行 sql 模糊表名匹配关闭之后 likeTable 与 notLikeTable 将失效,include 和 exclude 将使用内存过滤 ,如果有 sql 语法兼容性问题的话,请手动设置为 false
include需要包含的表名,当 enableSqlFilter 为 false 时,允许正则表达式(与 exclude 二选一配置)
likeTable自 3.3.0 起,模糊匹配表名(与 notLikeTable 二选一配置)
exclude需要排除的表名,当 enableSqlFilter 为 false 时,允许正则表达式
notLikeTable自 3.3.0 起,模糊排除表名
entityColumnConstant【实体】是否生成字段常量(默认 false)
entityBuilderModel【实体】是否为构建者模型(默认 false),自 3.3.2 开始更名为 chainModel
chainModel(since 3.3.2)【实体】是否为链式模型(默认 false)
entityLombokModel【实体】是否为 lombok 模型(默认 false)3.3.2 以下版本默认生成了链式模型,3.3.2 以后,默认不生成,如有需要,请开启 chainModel
entityBooleanColumnRemoveIsPrefixBoolean 类型字段是否移除 is 前缀(默认 false)
restControllerStyle生成 @RestController 控制器
controllerMappingHyphenStyle驼峰转连字符
entityTableFieldAnnotationEnable是否生成实体时,生成字段注解
versionFieldName乐观锁属性名称
logicDeleteFieldName逻辑删除属性名称
tableFillList表填充字段
		// 策略配置
		StrategyConfig strategy = new StrategyConfig();
		// strategy.setCapitalMode(true);// 全局大写命名
		// strategy.setDbColumnUnderline(true);//全局下划线命名
//		strategy.setTablePrefix(new String[] { "bmd_", "mp_" });// 此处可以修改为您的表前缀
		strategy.setNaming(NamingStrategy.underline_to_camel);// 表名生成策略
		// strategy.setInclude(new String[] { "user" }); // 需要生成的表
		// strategy.setExclude(new String[]{"test"}); // 排除生成的表
		// 自定义实体父类
		// strategy.setSuperEntityClass("com.baomidou.demo.TestEntity");
		// 自定义实体,公共字段
		// strategy.setSuperEntityColumns(new String[] { "test_id", "age" });
		// 自定义 mapper 父类
		// strategy.setSuperMapperClass("com.baomidou.demo.TestMapper");
		// 自定义 service 父类
		// strategy.setSuperServiceClass("com.baomidou.demo.TestService");
		// 自定义 service 实现类父类
		// strategy.setSuperServiceImplClass("com.baomidou.demo.TestServiceImpl");
		// 自定义 controller 父类
		strategy.setSuperControllerClass("com.wangzhixuan.commons.base.BaseController");
		// 【实体】是否生成字段常量(默认 false)
		// public static final String ID = "test_id";
		// strategy.setEntityColumnConstant(true);
		// 【实体】是否为构建者模型(默认 false)
		// public User setName(String name) {this.name = name; return this;}
		// strategy.setEntityBuliderModel(true);
		mpg.setStrategy(strategy);

注意 : 使用时,先看清楚归于哪一类的配置,避免出现找不到的情况!

三、MyBatis-Plus Generator

2.1、导入依赖

<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>com.wangzhixuan</groupId>
	<artifactId>school-management</artifactId>
	<packaging>war</packaging>
	<version>1.3.0</version>
	<name>school-management</name>
	<url>http://demo.dreamlu.net</url>

	<properties>
		<project.build.sourceEncoding>utf-8</project.build.sourceEncoding>
		<jdk.version>1.7</jdk.version>
		<junit.version>4.12</junit.version>
		<servlet.version>3.0.1</servlet.version>
		<log4j2.version>2.8.2</log4j2.version>
		<spring.version>4.3.8.RELEASE</spring.version>
		<mybaitsplus.version>2.0.8</mybaitsplus.version>
		<mysql.version>5.1.40</mysql.version>
		<druid.version>1.0.29</druid.version>
		<shiro.version>1.3.2</shiro.version>
		<ehcache.version>2.6.11</ehcache.version>
		<jackson.version>2.8.8</jackson.version>
		<commons-io.version>2.5</commons-io.version>
		<hibernate-validator.version>5.3.5.Final</hibernate-validator.version>
		<poi.version>3.16</poi.version>
	</properties>

	<dependencies>
		<!-- Spring begin -->
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-test</artifactId>
			<version>4.3.8.RELEASE</version>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-webmvc</artifactId>
			<version>4.3.8.RELEASE</version>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-jdbc</artifactId>
			<version>4.3.8.RELEASE</version>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-aspects</artifactId>
			<version>4.3.8.RELEASE</version>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-context-support</artifactId>
			<version>4.3.8.RELEASE</version>
		</dependency>
		<!-- spring end -->
		<dependency>
			<groupId>commons-io</groupId>
			<artifactId>commons-io</artifactId>
			<version>${commons-io.version}</version>
		</dependency>
		<!--Mybatis-Plus-->
		<dependency>
			<groupId>com.baomidou</groupId>
			<artifactId>mybatis-plus</artifactId>
			<version>${mybaitsplus.version}</version>
		</dependency>
		<dependency>
			<groupId>mysql</groupId>
			<artifactId>mysql-connector-java</artifactId>
			<version>${mysql.version}</version>
		</dependency>
		<dependency>
			<groupId>com.alibaba</groupId>
			<artifactId>druid</artifactId>
			<version>${druid.version}</version>
		</dependency>
		<dependency>
			<groupId>org.apache.velocity</groupId>
			<artifactId>velocity</artifactId>
			<version>1.7</version>
		</dependency>
	</dependencies>


	<!-- 使用aliyun镜像 -->
	<repositories>
		<repository>
			<id>aliyun</id>
			<name>aliyun</name>
			<url>http://maven.aliyun.com/nexus/content/groups/public</url>
		</repository>
	</repositories>

</project>

2.2、运行类(放在测试类中即可)

package com.wangzhixuan.generator;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;

import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PropertiesLoaderUtils;

import com.baomidou.mybatisplus.generator.AutoGenerator;
import com.baomidou.mybatisplus.generator.InjectionConfig;
import com.baomidou.mybatisplus.generator.config.DataSourceConfig;
import com.baomidou.mybatisplus.generator.config.FileOutConfig;
import com.baomidou.mybatisplus.generator.config.GlobalConfig;
import com.baomidou.mybatisplus.generator.config.PackageConfig;
import com.baomidou.mybatisplus.generator.config.StrategyConfig;
import com.baomidou.mybatisplus.generator.config.converts.MySqlTypeConvert;
import com.baomidou.mybatisplus.generator.config.po.TableInfo;
import com.baomidou.mybatisplus.generator.config.rules.DbType;
import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
import com.baomidou.mybatisplus.toolkit.StringUtils;

/**
 * <p>
 * 代码生成器演示
 * </p>
 * 
 * @author goujiatao
 * @date 2016-12-01
 */
public class MysqlGenerator {

	/**
	 * <p>
	 * MySQL 生成演示
	 * </p>
	 */
	public static void main(String[] args) {
		/* 获取 JDBC 配置文件 */
		Properties props = getProperties();
		AutoGenerator mpg = new AutoGenerator();

		//String outputDir = "/Users/lcm/Desktop/generator/code";
		String outputDir = "C:/Users/Administrator/Desktop/新建文件夹";
		final String viewOutputDir = outputDir + "/view/";
		
		// 全局配置
		GlobalConfig gc = new GlobalConfig();
		gc.setOutputDir(outputDir);
		gc.setFileOverride(true);
		gc.setActiveRecord(true);// 开启 activeRecord 模式
		gc.setEnableCache(false);// XML 二级缓存
		gc.setBaseResultMap(true);// XML ResultMap
		gc.setBaseColumnList(false);// XML columList
		gc.setAuthor("zhixuan.wang");

		// 自定义文件命名,注意 %s 会自动填充表实体属性!
		gc.setMapperName("%sMapper");
		gc.setXmlName("%sMapper");
		gc.setServiceName("I%sService");
		gc.setServiceImplName("%sServiceImpl");
		gc.setControllerName("%sController");
		mpg.setGlobalConfig(gc);

		// 数据源配置
		DataSourceConfig dsc = new DataSourceConfig();
		dsc.setDbType(DbType.MYSQL);
		dsc.setTypeConvert(new MySqlTypeConvert());
		dsc.setDriverName("com.mysql.jdbc.Driver");
		dsc.setUsername(props.getProperty("db.master.user"));
		dsc.setPassword(props.getProperty("db.master.password"));
		dsc.setUrl(props.getProperty("db.master.url"));
		mpg.setDataSource(dsc);

		// 策略配置
		StrategyConfig strategy = new StrategyConfig();
		// strategy.setCapitalMode(true);// 全局大写命名
		// strategy.setDbColumnUnderline(true);//全局下划线命名
//		strategy.setTablePrefix(new String[] { "bmd_", "mp_" });// 此处可以修改为您的表前缀
		strategy.setNaming(NamingStrategy.underline_to_camel);// 表名生成策略
		// strategy.setInclude(new String[] { "user" }); // 需要生成的表
		// strategy.setExclude(new String[]{"test"}); // 排除生成的表
		// 自定义实体父类
		// strategy.setSuperEntityClass("com.baomidou.demo.TestEntity");
		// 自定义实体,公共字段
		// strategy.setSuperEntityColumns(new String[] { "test_id", "age" });
		// 自定义 mapper 父类
		// strategy.setSuperMapperClass("com.baomidou.demo.TestMapper");
		// 自定义 service 父类
		// strategy.setSuperServiceClass("com.baomidou.demo.TestService");
		// 自定义 service 实现类父类
		// strategy.setSuperServiceImplClass("com.baomidou.demo.TestServiceImpl");
		// 自定义 controller 父类
		strategy.setSuperControllerClass("com.wangzhixuan.commons.base.BaseController");
		// 【实体】是否生成字段常量(默认 false)
		// public static final String ID = "test_id";
		// strategy.setEntityColumnConstant(true);
		// 【实体】是否为构建者模型(默认 false)
		// public User setName(String name) {this.name = name; return this;}
		// strategy.setEntityBuliderModel(true);
		mpg.setStrategy(strategy);

		// 包配置
		PackageConfig pc = new PackageConfig();
		pc.setModuleName(null);  //所属模块
		pc.setParent("com.wangzhixuan"); // 自定义包路径
		pc.setController("controller"); // 这里是控制器包名,默认 web
		pc.setEntity("model");
		pc.setXml("sqlMapperXml");
		mpg.setPackageInfo(pc);

		// 注入自定义配置,可以在 VM 中使用 cfg.abc 设置的值
		InjectionConfig cfg = new InjectionConfig() {
			@Override
			public void initMap() {}
		};
		// 生成的模版路径,不存在时需要先新建
		File viewDir = new File(viewOutputDir);
		if (!viewDir.exists()) {
			viewDir.mkdirs();
		}
		List<FileOutConfig> focList = new ArrayList<FileOutConfig>();
		focList.add(new FileOutConfig("/templates/add.jsp.vm") {
			@Override
			public String outputFile(TableInfo tableInfo) {
				return getGeneratorViewPath(viewOutputDir, tableInfo, "Add.jsp");
			}
		});
		focList.add(new FileOutConfig("/templates/edit.jsp.vm") {
			@Override
			public String outputFile(TableInfo tableInfo) {
				return getGeneratorViewPath(viewOutputDir, tableInfo, "Edit.jsp");
			}
		});
		focList.add(new FileOutConfig("/templates/list.jsp.vm") {
			@Override
			public String outputFile(TableInfo tableInfo) {
				return getGeneratorViewPath(viewOutputDir, tableInfo, "List.jsp");
			}
		});
		cfg.setFileOutConfigList(focList);
		mpg.setCfg(cfg);

		// 执行生成
		mpg.execute();
	}

	/**
	 * 获取配置文件
	 *
	 * @return 配置Props
	 */
	private static Properties getProperties() {
		// 读取配置文件
		Resource resource = new ClassPathResource("/config/application.properties");
		Properties props = new Properties();
		try {
			props = PropertiesLoaderUtils.loadProperties(resource);
		} catch (IOException e) {
			e.printStackTrace();
		}
		return props;
	}
	
	/**
	 * 页面生成的文件名
	 */
	private static String getGeneratorViewPath(String viewOutputDir, TableInfo tableInfo, String suffixPath) {
		String name = StringUtils.firstToLowerCase(tableInfo.getEntityName());
		String path = viewOutputDir + "/" + name + "/" + name + suffixPath;
		File viewDir = new File(path).getParentFile();
		if (!viewDir.exists()) {
			viewDir.mkdirs();
		}
		return path;
	}
}

2.4、运行结果

在这里插入图片描述

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

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

相关文章

高级篇七、InnoDB数据存储结构

1、数据库的存储结构&#xff1a; 页 1.1 磁盘与内存交互的基本单位&#xff1a;页 1.2 页结构概述 页a&#xff0c;页b&#xff0c;页c … 页n 这些页可以不在物理结构上相连&#xff0c;只要通过双向链表相关联即可每个数据页中的记录会按照主键值从小到大的顺序组成一个单项…

Qt5.12实战之图形编程初识

演示效果: 1.绘制条件: 1. 绘图设备-> QPainter 2.画笔->QPen --->字体 (QFont) 3.画刷->QBrush-->自己定义画刷(QPixmap) 4.绘制事件->QPaintEvent 绘图步骤: 1.重写基类的虚函数 void paintEvent(QPaintEvent *event); 2.在虚函数 void paintEvent…

C++---状态压缩dp---愤怒的小鸟(每日一道算法2023.4.19)

注意事项&#xff1a; 难度警告&#xff01;这题在NOIP中也算偏难的题&#xff0c;量力而行。 本题为"状态压缩dp—最短Hamilton路径"的扩展题&#xff0c;建议先阅读这篇文章并理解。 本题是"重复覆盖问题"可以使用"Dancing Links"做&#xff0…

MySql-高级( 面试问题简析) 学习笔记

文章目录 1. MySql 中 MyISAM 和 InnoDB 存储引擎区别1.1. MyISAM1.2. InnoDB 2. 索引的数据结构2.1. B Tree索引2.2. BTree索引2.3. MySql 做的优化 3. 为什么使用BTree索引而不使用Hash索引&#xff1f;4. 为什么使用BTree索引而不使用B-Tree索引&#xff1f;5. MyISAM 存储引…

检测并打印C++编译器支持的feature(附Visual Studio 2022测试结果)

C标准快速迭代&#xff0c;不同的系统平台和编译器对C各种新功能的支持不同&#xff0c;通过这个程序可以测试所用编译器对各个版本C的支持情况。另一方面&#xff0c;可以在代码中通过这些宏针对不同版本编写不同的代码分支。 源码下面附上Visual Studio 2022的测试结果&#…

【字符串处理】

目录 总结&#xff1a; 只要一做字符串的题目必出bug&#xff0c; 本蒟蒻还是要开个专题写一下……懒狗直接引用chatgpt 在C中&#xff0c;我们可以使用以下几种方式进行字符串的输入&#xff1a; 1.使用输入运算符(>>): 可以按照空格分隔符把一个标准字符串(即不包含…

引用的底层原理(汇编指令),引用与指针的联系与区别

TIPS 2. 3. 4. 引用的底层本质 在语法层面上的话&#xff0c;这个引用是不开空间的&#xff0c;相当于是对一个变量进行一个取别名的这么一个操作。在底层实现上实际是有空间的&#xff0c;因为引用是按照指针方式来实现的。然而如果你从底层的角度去看的话&#xff0c;因…

两小时让你全方位的认识文件(完结)

上期阿博给友友们讲了一些关于文件的一些读写操作&#xff0c;这期给友友们分享一下二进制的方式和文件操作的一些误区&#xff0c;下面来跟着阿博走进文件吧&#x1f917;&#x1f917;&#x1f917; 文章目录 一.fread和fwrite功能介绍二.文件的随机读写三.文本文件和二进制文…

17.网络爬虫—Scrapy入门与实战

这里写目录标题 Scrapy基础Scrapy运行流程原理Scrapy的工作流程Scrapy的优点 Scrapy基本使用(豆瓣网为例)创建项目创建爬虫配置爬虫运行爬虫如何用python执行cmd命令数据解析打包数据打开管道pipeline使用注意点 后记 前言&#xff1a; &#x1f3d8;️&#x1f3d8;️个人简介…

第一章Git学习(尚硅谷新版Git快速入门)

文章目录 为什么要学习Git为什么要学习Git软件为什么要学习Git软件Git基础概念版本控制集中式、分布式版本控制的区别Git工作区域Git分支 版本号什么是版本号文件操作对应的版本号分支操作对应的原理 命令行操作Git相关配置的指令获取当前Git的配置信息名称和邮箱 Git文件操作相…

随笔-你买罐头干什么

生产环境不太稳定&#xff0c;正在挠头&#xff0c;想着怎么能解决这个问题。 聊天工具上突然弹出一张图片&#xff0c;是个不认识的人&#xff08;暂且称为Z&#xff09;发的。点进去一看&#xff0c;是从一个表格截取的一条数据&#xff0c;内容是我某次加班餐的订单。 Z&a…

带头单向链表源码及相关练习

目录 移除链表元素 链表的中间节点 链表倒数第k个节点 合并两个有序链表 相交链表 环形链表 环形链表2 分割链表 回文链表 public class MySingleList {//内部类的使用class ListNode {public int val;public ListNode next;public ListNode(int val) {this.val val;}…

Java基础:容器知识点

目录 1、Java容器都有哪些&#xff1f; 2、Collection 和 Collections 区别&#xff1f; 3、List、Set、Map 间的区别&#xff1f; 4、HashMap 和 Hashtable 区别&#xff1f; 5、如何决定用 HashMap 还是 TreeMap&#xff1f; 6、HashMap 的实现原理&#xff1f; 7、说…

浮点型在内存中的存储

常见的浮点数&#xff1a; 3.14159 1E10&#xff08;科学计数法&#xff1a;1.0*10^10&#xff09; 浮点数家族包括&#xff1a; float、double、long double 类型 浮点数表示的范围&#xff1a;float.h中定义 下面举一个例子&#xff1a; int main() {int n 9;float *pFloat…

动态规划专练(一)

文章目录 前言一、斐波那契数1.题目介绍2.思路3.代码 二、爬楼梯1.题目介绍2.思路3.代码 三、使用最小花费爬楼梯1.题目介绍2.思路3.代码 前言 此篇为动态规划的初阶篇&#xff0c;所以比较简单&#xff0c;适合刚入门的新手学&#xff0c;如果你已经入门了&#xff0c;就无需看…

[LeetCode]杨辉三角

给定一个非负整数 numRows&#xff0c;生成「杨辉三角」的前 numRows 行。 在「杨辉三角」中&#xff0c;每个数是它左上方和右上方的数的和。 给定一个非负整数 numRows&#xff0c;生成「杨辉三角」的前 numRows 行。 在「杨辉三角」中&#xff0c;每个数是它左上方和右上…

(三)Python-tkinter桌面应用(爱心雨)

&#xff08;三&#xff09;Python-tkinter桌面应用&#xff08;爱心雨&#xff09; 一、前言 我们已经了解到tkinter可以制作爱心&#xff0c;弹幕&#xff0c;为了能让他看起来更加的充满心意&#xff0c;于是&#xff0c;我们决定将他制作为爱心雨。让它看起来更加的特别&a…

字节测试总监深度剖析,都2023年了,测试用例还不重视起来

​ 测试用例对于测试工作的作用&#xff1a; 1、指导测试的实施 测试用例主要适用于集成测试、系统测试和回归测试。在实施测试时测试用例作为测试的标准&#xff0c;测试人员一定要按照测试用例严格按用例项目和测试步骤逐一实施测试。并对测试情况记录在测试用例管理软件中…

超长JVM总结,面试必备

目录 什么是JVM JVM内存区域 JVM运行时内存(jdk1.7) 垃圾回收与算法 分代收集算法 GC 分代收集算法 VS 分区收集算法 GC 垃圾收集器 什么是JVM JVM 是可运行 Java 代码的假想计算机 &#xff0c;包括一套字节码指令集、一组寄存器、一个栈、一个垃圾回收&#xff0c;…

ChatGPT已死?AutoGPT太强?

今天聊聊 AutoGPT。 OpenAI 的 Andrej Karpathy 都大力宣传&#xff0c;认为 AutoGPT 是 prompt 工程的下一个前沿。 近日&#xff0c;AI 界貌似出现了一种新的趋势&#xff1a;自主人工智能。 这不是空穴来风&#xff0c;最近一个名为 AutoGPT 的研究开始走进大众视野。特斯拉…