MyBatis Generator使用总结

news2025/9/20 6:44:09

MyBatis Generator使用总结

  • 介绍
  • 具体使用
    • 数据准备
    • 插件引入
    • 配置
    • 条件构建讲解
    • demo地址

介绍

MyBatis Generator (MBG) 是 MyBatis 的代码生成器。它能够根据数据库表,自动生成 java 实体类、dao 层接口(mapper 接口)及mapper.xml文件。

具体使用

数据准备

创建数据库(8.0版本)mybatis,并添加一张表rbac_user,用于测试

CREATE TABLE `rbac_user` (
  `id` int NOT NULL AUTO_INCREMENT COMMENT '主鍵',
  `name` varchar(100) DEFAULT NULL COMMENT '用户名',
  `email` varchar(100) DEFAULT NULL COMMENT '邮箱',
  `nick_name` varchar(100) DEFAULT NULL COMMENT '昵称',
  `remark` varchar(100) DEFAULT NULL COMMENT '备注',
  `create_time` date DEFAULT NULL COMMENT '创建时间',
  `status` char(1) DEFAULT NULL COMMENT '状态',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='用户表';

如图所示:
在这里插入图片描述

插件引入

创建一个SpringBoot项目这里使用的spring boot版本是2.1.3.RELEASE,将mybatis 插件引入

		  <!--SpringBoot通用依赖模块-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-aop</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

        <!--SpringBoot整合MyBatis-->
        <dependency>
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>mybatis-spring-boot-starter</artifactId>
            <version>2.2.2</version>
        </dependency>
        <!--MyBatis分页插件-->
        <dependency>
            <groupId>com.github.pagehelper</groupId>
            <artifactId>pagehelper-spring-boot-starter</artifactId>
            <version>1.4.5</version>
        </dependency>
        <!--集成druid连接池-->
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>druid-spring-boot-starter</artifactId>
            <version>1.2.9</version>
        </dependency>
        <!-- MyBatis 生成器 -->
        <dependency>
            <groupId>org.mybatis.generator</groupId>
            <artifactId>mybatis-generator-core</artifactId>
            <version>1.4.1</version>
        </dependency>
        <!--Mysql数据库驱动-->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>8.0.15</version>
        </dependency>
        <!--springfox swagger官方Starter-->
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger2</artifactId>
            <version>2.9.2</version>
        </dependency>
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger-ui</artifactId>
            <version>2.9.2</version>
        </dependency>

配置

1、对项目的application.yml进行配置:

server:
  port: 8080

spring:
  datasource:
    url: jdbc:mysql://localhost:3306/mybatis?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai
    username: root
    password: root
  mvc:
    pathmatch:
      matching-strategy: ANT_PATH_MATCHER

mybatis:
  mapper-locations:
    - classpath:dao/*.xml
  configuration:
    # 下划线自动转驼峰
    map-underscore-to-camel-case: true

logging:
  level:
    root: info
    com.sheep: debug

2、创建配置文件为generator.properties,添加数据库配置信息,用于代码生成器配置使用:

jdbc.driverClass=com.mysql.cj.jdbc.Driver
jdbc.connectionURL=jdbc:mysql://localhost:3306/mybatis?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai
jdbc.userId=root
jdbc.password=root

3、创建代码生成器配置文件generatorConfig.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE generatorConfiguration PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
        "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">

<generatorConfiguration>
    <properties resource="generator.properties"/>
    <context id="MySqlContext" targetRuntime="MyBatis3" defaultModelType="flat">
        <!-- 配置SQL语句中的前置分隔符 -->
        <property name="beginningDelimiter" value="`"/>
        <!-- 配置SQL语句中的后置分隔符 -->
        <property name="endingDelimiter" value="`"/>
        <!-- 配置生成Java文件的编码 -->
        <property name="javaFileEncoding" value="UTF-8"/>
        <!-- 为模型生成序列化方法 -->
        <plugin type="org.mybatis.generator.plugins.SerializablePlugin"/>
        <!-- 为生成的Java模型创建一个toString方法 -->
        <plugin type="org.mybatis.generator.plugins.ToStringPlugin"/>
        <!-- 生成mapper.xml时覆盖原文件 -->
        <plugin type="org.mybatis.generator.plugins.UnmergeableXmlMappersPlugin" />
        <commentGenerator type="com.macro.mall.CommentGenerator">
            <!-- 是否阻止生成的注释 -->
            <property name="suppressAllComments" value="true"/>
            <!-- 是否阻止生成的注释包含时间戳 -->
            <property name="suppressDate" value="true"/>
            <!-- 是否添加数据库表的备注信息 -->
            <property name="addRemarkComments" value="true"/>
        </commentGenerator>
        <!--配置数据库连接-->
        <jdbcConnection driverClass="${jdbc.driverClass}"
                        connectionURL="${jdbc.connectionURL}"
                        userId="${jdbc.userId}"
                        password="${jdbc.password}">
            <!--解决mysql驱动升级到8.0后不生成指定数据库代码的问题-->
            <property name="nullCatalogMeansCurrent" value="true"/>
        </jdbcConnection>
        <!--指定生成model的路径-->
        <javaModelGenerator targetPackage="com.sheep.mbg.model" targetProject="learn-mybatis\src\main\java"/>
        <!--指定生成mapper.xml的路径-->
        <sqlMapGenerator targetPackage="com.sheep..mbg.mapper" targetProject="learn-mybatis\src\main\resources"/>
        <!--指定生成mapper接口的的路径-->
        <javaClientGenerator type="XMLMAPPER" targetPackage="com.sheep.mbg.mapper" targetProject="learn-mybatis\src\main\java"/>
      	<!--配置需要生成的表,生成全部表tableName设为% 还可以指定统一前缀的表 如 rbac_% 表示所有rbac_开始的所有表-->
        <table tableName="rbac_%">
            <generatedKey column="id" sqlStatement="MySql" identity="true"/>
        </table>
    </context>
</generatorConfiguration>

4、实际开发中,有的项目是需要接入swagger-ui的,所以字段注释就得自定义。建立一个注释自定义处理类CommentGenerator:

import org.mybatis.generator.api.IntrospectedColumn;
import org.mybatis.generator.api.IntrospectedTable;
import org.mybatis.generator.api.dom.java.CompilationUnit;
import org.mybatis.generator.api.dom.java.Field;
import org.mybatis.generator.api.dom.java.FullyQualifiedJavaType;
import org.mybatis.generator.internal.DefaultCommentGenerator;
import org.mybatis.generator.internal.util.StringUtility;

import java.util.Properties;

/**
 * 自定义注释生成器
 */
public class CommentGenerator extends DefaultCommentGenerator {
    private boolean addRemarkComments = false;
    private static final String EXAMPLE_SUFFIX = "Example";
    private static final String MAPPER_SUFFIX = "Mapper";
    private static final String API_MODEL_PROPERTY_FULL_CLASS_NAME = "io.swagger.annotations.ApiModelProperty";

    /**
     * 设置用户配置的参数
     */
    @Override
    public void addConfigurationProperties(Properties properties) {
        super.addConfigurationProperties(properties);
        this.addRemarkComments = StringUtility.isTrue(properties.getProperty("addRemarkComments"));
    }

    /**
     * 给字段添加注释
     */
    @Override
    public void addFieldComment(Field field, IntrospectedTable introspectedTable,
                                IntrospectedColumn introspectedColumn) {
        String remarks = introspectedColumn.getRemarks();
        //根据参数和备注信息判断是否添加swagger注解信息
        if (addRemarkComments && StringUtility.stringHasValue(remarks)) {
//            addFieldJavaDoc(field, remarks);
            //数据库中特殊字符需要转义
            if (remarks.contains("\"")) {
                remarks = remarks.replace("\"", "'");
            }
            //给model的字段添加swagger注解
            field.addJavaDocLine("@ApiModelProperty(value = \"" + remarks + "\")");
        }
    }

    /**
     * 给model的字段添加注释
     */
    private void addFieldJavaDoc(Field field, String remarks) {
        //文档注释开始
        field.addJavaDocLine("/**");
        //获取数据库字段的备注信息
        String[] remarkLines = remarks.split(System.getProperty("line.separator"));
        for (String remarkLine : remarkLines) {
            field.addJavaDocLine(" * " + remarkLine);
        }
        addJavadocTag(field, false);
        field.addJavaDocLine(" */");
    }

    @Override
    public void addJavaFileComment(CompilationUnit compilationUnit) {
        super.addJavaFileComment(compilationUnit);
        //只在model中添加swagger注解类的导入
        if (!compilationUnit.getType().getFullyQualifiedName().contains(MAPPER_SUFFIX) && !compilationUnit.getType().getFullyQualifiedName().contains(EXAMPLE_SUFFIX)) {
            compilationUnit.addImportedType(new FullyQualifiedJavaType(API_MODEL_PROPERTY_FULL_CLASS_NAME));
        }
    }
}

5、添加运行类Generator:

import org.mybatis.generator.api.MyBatisGenerator;
import org.mybatis.generator.config.Configuration;
import org.mybatis.generator.config.xml.ConfigurationParser;
import org.mybatis.generator.internal.DefaultShellCallback;

import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;

public class Generator {
    public static void main(String[] args) throws Exception {
        //MBG 执行过程中的警告信息
        List<String> warnings = new ArrayList<String>();
        //当生成的代码重复时,覆盖原代码
        boolean overwrite = true;
        //读取我们的 MBG 配置文件
        InputStream is = Generator.class.getResourceAsStream("/generatorConfig.xml");
        ConfigurationParser cp = new ConfigurationParser(warnings);
        Configuration config = cp.parseConfiguration(is);
        is.close();

        DefaultShellCallback callback = new DefaultShellCallback(overwrite);
        //创建 MBG
        MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, callback, warnings);
        //执行生成代码
        myBatisGenerator.generate(null);
        //输出警告信息
        for (String warning : warnings) {
            System.out.println(warning);
        }
    }
}

6、运行后看结果:图中的路径是与配置文件相对应的。若不存在也会自动创建目录

生成结果
7、可以看到model对象中的各个字段的注释。
在这里插入图片描述
8、还有另个自动生成的对象类:此对象是为了配合增删改查的条件构建用的。
在这里插入图片描述
9、看下生成的Mapper接口,这里生成了基本增删改查操作的接口,查询参数也应用了删改你的条件构建对象。
mapper
10、构建RbacUserService,RbacUserController。具体讲解下这个条件构建器如何使用:

public interface RbacUserService {
    List<RbacUser> listAllUser();

    int createUser(RbacUser user);

    int updateUser(Integer id, RbacUser user);

    int deleteUser(Integer id);

    List<RbacUser> listUser(int pageNum, int pageSize);

    RbacUser getUser(Integer id);
}
@Service
public class RbacUserServiceImpl implements RbacUserService {
    @Autowired
    private RbacUserMapper userMapper;

    @Override
    public List<RbacUser> listAllUser() {
        return userMapper.selectByExample(new RbacUserExample());
    }

    @Override
    public int createUser(RbacUser user) {
        return userMapper.insert(user);
    }

    @Override
    public int updateUser(Integer id, RbacUser user) {
        user.setId(id);
        return userMapper.updateByPrimaryKeySelective(user);
    }

    @Override
    public int deleteUser(Integer id) {
        return userMapper.deleteByPrimaryKey(id);
    }

    @Override
    public List<RbacUser> listUser(int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        return userMapper.selectByExample(new RbacUserExample());
    }

    @Override
    public RbacUser getUser(Integer id) {
        return userMapper.selectByPrimaryKey(id);
    }
}
@Api("用户管理")
@Controller
@RequestMapping("/user")
public class RbacUserController {
    private static final Logger LOGGER = LoggerFactory.getLogger(RbacUserController.class);
    @Autowired
    private RbacUserService userService;

    @ApiOperation("获取所有用户列表")
    @RequestMapping(value = "listAll", method = RequestMethod.GET)
    @ResponseBody
    public CommonResult<List<RbacUser>> getUserList() {
        return CommonResult.success(userService.listAllUser());
    }

    @ApiOperation("添加用户")
    @RequestMapping(value = "/create", method = RequestMethod.POST)
    @ResponseBody
    public CommonResult createUser(@RequestBody RbacUser user) {
        CommonResult commonResult;
        int count = userService.createUser(user);
        if (count == 1) {
            commonResult = CommonResult.success(user);
            LOGGER.debug("createUser success:{}", user);
        } else {
            commonResult = CommonResult.failed("操作失败");
            LOGGER.debug("createUser failed:{}", user);
        }
        return commonResult;
    }

    @ApiOperation("更新指定id用户信息")
    @RequestMapping(value = "/update/{id}", method = RequestMethod.POST)
    @ResponseBody
    public CommonResult updateUser(@PathVariable("id") Integer id, @RequestBody RbacUser user, BindingResult result) {
        CommonResult commonResult;
        int count = userService.updateUser(id, user);
        if (count == 1) {
            commonResult = CommonResult.success(user);
            LOGGER.debug("updateUser success:{}", user);
        } else {
            commonResult = CommonResult.failed("操作失败");
            LOGGER.debug("updateUser failed:{}", user);
        }
        return commonResult;
    }

    @ApiOperation("删除指定id的用户")
    @RequestMapping(value = "/delete/{id}", method = RequestMethod.GET)
    @ResponseBody
    public CommonResult deleteUser(@PathVariable("id") Integer id) {
        int count = userService.deleteUser(id);
        if (count == 1) {
            LOGGER.debug("deleteUser success :id={}", id);
            return CommonResult.success(null);
        } else {
            LOGGER.debug("deleteUser failed :id={}", id);
            return CommonResult.failed("操作失败");
        }
    }

    @ApiOperation("分页查询用户列表")
    @RequestMapping(value = "/list", method = RequestMethod.GET)
    @ResponseBody
    public CommonResult<CommonPage<RbacUser>> listUser(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum, @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
        List<RbacUser> brandList = userService.listUser(pageNum, pageSize);
        return CommonResult.success(CommonPage.restPage(brandList));
    }

    @ApiOperation("获取指定id的品牌详情")
    @RequestMapping(value = "/{id}", method = RequestMethod.GET)
    @ResponseBody
    public CommonResult<RbacUser> user(@PathVariable("id") Integer id) {
        return CommonResult.success(userService.getUser(id));
    }
}

11、controller中的返回结果进行了统一,代码如下,可以自行修改:

public interface IErrorCode {
    long getCode();

    String getMessage();
}
public enum ResultCode implements IErrorCode {
    SUCCESS(200, "操作成功"),
    FAILED(500, "操作失败"),
    VALIDATE_FAILED(404, "参数检验失败"),
    UNAUTHORIZED(401, "暂未登录或token已经过期"),
    FORBIDDEN(403, "没有相关权限");
    private long code;
    private String message;

    private ResultCode(long code, String message) {
        this.code = code;
        this.message = message;
    }

    public long getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }
}
public class CommonPage<T> {
    private Integer pageNum;
    private Integer pageSize;
    private Integer totalPage;
    private Long total;
    private List<T> list;

    /**
     * 将PageHelper分页后的list转为分页信息
     */
    public static <T> CommonPage<T> restPage(List<T> list) {
        CommonPage<T> result = new CommonPage<T>();
        PageInfo<T> pageInfo = new PageInfo<T>(list);
        result.setTotalPage(pageInfo.getPages());
        result.setPageNum(pageInfo.getPageNum());
        result.setPageSize(pageInfo.getPageSize());
        result.setTotal(pageInfo.getTotal());
        result.setList(pageInfo.getList());
        return result;
    }


    public Integer getPageNum() {
        return pageNum;
    }

    public void setPageNum(Integer pageNum) {
        this.pageNum = pageNum;
    }

    public Integer getPageSize() {
        return pageSize;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }

    public Integer getTotalPage() {
        return totalPage;
    }

    public void setTotalPage(Integer totalPage) {
        this.totalPage = totalPage;
    }

    public List<T> getList() {
        return list;
    }

    public void setList(List<T> list) {
        this.list = list;
    }

    public Long getTotal() {
        return total;
    }

    public void setTotal(Long total) {
        this.total = total;
    }
}
public class CommonResult<T> {
    private long code;
    private String message;
    private T data;

    protected CommonResult() {
    }

    protected CommonResult(long code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    /**
     * 成功返回结果
     *
     * @param data 获取的数据
     */
    public static <T> CommonResult<T> success(T data) {
        return new CommonResult<T>(ResultCode.SUCCESS.getCode(), ResultCode.SUCCESS.getMessage(), data);
    }

    /**
     * 成功返回结果
     *
     * @param data    获取的数据
     * @param message 提示信息
     */
    public static <T> CommonResult<T> success(T data, String message) {
        return new CommonResult<T>(ResultCode.SUCCESS.getCode(), message, data);
    }

    /**
     * 失败返回结果
     *
     * @param errorCode 错误码
     */
    public static <T> CommonResult<T> failed(IErrorCode errorCode) {
        return new CommonResult<T>(errorCode.getCode(), errorCode.getMessage(), null);
    }

    /**
     * 失败返回结果
     *
     * @param message 提示信息
     */
    public static <T> CommonResult<T> failed(String message) {
        return new CommonResult<T>(ResultCode.FAILED.getCode(), message, null);
    }

    /**
     * 失败返回结果
     */
    public static <T> CommonResult<T> failed() {
        return failed(ResultCode.FAILED);
    }

    /**
     * 参数验证失败返回结果
     */
    public static <T> CommonResult<T> validateFailed() {
        return failed(ResultCode.VALIDATE_FAILED);
    }

    /**
     * 参数验证失败返回结果
     *
     * @param message 提示信息
     */
    public static <T> CommonResult<T> validateFailed(String message) {
        return new CommonResult<T>(ResultCode.VALIDATE_FAILED.getCode(), message, null);
    }

    /**
     * 未登录返回结果
     */
    public static <T> CommonResult<T> unauthorized(T data) {
        return new CommonResult<T>(ResultCode.UNAUTHORIZED.getCode(), ResultCode.UNAUTHORIZED.getMessage(), data);
    }

    /**
     * 未授权返回结果
     */
    public static <T> CommonResult<T> forbidden(T data) {
        return new CommonResult<T>(ResultCode.FORBIDDEN.getCode(), ResultCode.FORBIDDEN.getMessage(), data);
    }

    public long getCode() {
        return code;
    }

    public void setCode(long code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
@Configuration
@EnableSwagger2
public class Swagger2Config {
    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                //为当前包下controller生成API文档
				 .apis(RequestHandlerSelectors.basePackage("com.sheep.controller"))
                .paths(PathSelectors.any())
                .build();
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("SwaggerUI演示")
                .description("learn-mybatis")
                .contact(new Contact("sheep", "", "123@qq.com"))
                .version("1.0")
                .build();
    }
}

12、运行服务:
在这里插入图片描述
13、访问 http://localhost:8080/swagger-ui.html
在这里插入图片描述
成功启动。

条件构建讲解

从上面可以看到MyBatis Generator (MBG) 为每个数据库表生成了一个对应的 Example 类。它主要用于生成动态 SQL 语句。

Example 类允许你构建复杂的 WHERE 子句,而无需直接在 mapper 文件中硬编码 SQL,它包含了很多用于构建 WHERE 子句的方法。每个方法都对应一个 SQL 比较运算符,比如 “=”, “<>”, “>”, “<”, “LIKE” 等。你可以动态地添加、修改或删除查询条件。使用 Example 类,你可以构建几乎任何类型的查询,包括带有 AND 和 OR 子句的查询,带有子查询的查询等。

在使用 Example 类时,你需要创建一个 Example 对象,然后通过调用该对象的 createCriteria() 方法创建一个 Criteria 对象。然后你可以在 Criteria 对象上调用各种方法来添加查询条件。

上面的案例基本上都没用到,下面我们就开始使用这个条件构建器:

上面的案例是查询的所有用户,我们基于这个进行条件查询。
在这里插入图片描述
比如 对名字进行模糊查询:
在这里插入图片描述

Criteria 对象创建后,可以调用里面的各个接口进行构建参数,这个里面会对每个参数生成 “=”, “<>”, “>”, “<”, “LIKE” 的查询接口。如图所示是上面的接口详情:可以看到默认的情况,不会加%的
在这里插入图片描述
再看addCriterion,可以看到是往全局变量list中插入不同的条件构建对象。
在这里插入图片描述
在这里插入图片描述
看下查询语句拼接效果:
在这里插入图片描述

若我们查询有多个条件的话,直接继续添加即可,例如我可以根据name模糊查询,还要查询小于指定时间创建的用户
在这里插入图片描述

上面的是不同条件进行and拼接的,若使用or进行拼接不同条件的话,需要换个方式:
在这里插入图片描述

每个条件都需要通过or创建Criteria 对象,然后再赋值,看下or接口就明白了:
在这里插入图片描述
比如 我们查询的话还需要根据指定的字段进行排序:
在这里插入图片描述

可以看到在mapper中的条件构建判断逻辑:
在这里插入图片描述

这个构建器只能用来生成简单的基于单表的 CRUD 操作的代码。对于更复杂的 SQL 操作,比如子查询、Group 查询和 Join 查询,MBG 并不直接支持。这些复杂查询需要你自己在 Mapper 的 xml 文件或基于注解编写相应的 SQL。

demo地址

项目地址: https://gitee.com/yang1112/learn-project.git

我额外还写了一个根据模板生成代码,包括service、dao、mapper,有兴趣的可以看看:
项目地址: https://gitee.com/yang1112/code-generator.git

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

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

相关文章

OpenCV检测圆形东西是否存在缺口?

文章目录 前言一、试过的方法二、最终使用的方法1.先极坐标变换2.计算斜率 总结 前言 想了挺久&#xff0c;一直没解决这个问题。后面勉强解决了。 一、试过的方法 1.想用圆度来解决&#xff0c;后来发现圆度差值很小&#xff0c;完整的圆圆度0.89&#xff0c;然后有缺角的圆圆…

性能测试【二】:nmon的常用操作

性能测试【二】&#xff1a;nmon的常用操作 1、nmon介绍说明2、软件下载2.1、Nmon下载地址2.2、Nmonanalyser下载地址 3、nmon使用3.1、将nmon上传至/usr/local/src目录下&#xff0c;并解压3.2、解压后根据自己系统的实际版本查找相应的使用命令&#xff0c;并给命令赋予可执行…

springboot函数式web

1.通常是路由(请求路径)业务 2.函数式web&#xff1a;路由和业务分离 一个configure类 配置bean 路由等 实现业务逻辑 这样实现了业务和路由的分离

Yolov8训练自己的数据集过程

做自己第一次使用Yolov8的记录。 1、下载代码 官网的我没找到对应的视频教程&#xff0c;操作起来麻烦&#xff0c;一下这个链接的代码可以有对应bilibili教程&#xff1a;完整且详细的Yolov8复现训练自己的数据集 选择这个下载&#xff1a; 2、安装需要的包&#xff1a; 按…

2018年10月16日 Go生态洞察:App Engine新Go 1.11运行时发布

&#x1f337;&#x1f341; 博主猫头虎&#xff08;&#x1f405;&#x1f43e;&#xff09;带您 Go to New World✨&#x1f341; &#x1f984; 博客首页——&#x1f405;&#x1f43e;猫头虎的博客&#x1f390; &#x1f433; 《面试题大全专栏》 &#x1f995; 文章图文…

项目中启用Log4j2日志框架

在实际的项目开发中&#xff0c;日志十分重要&#xff0c;无论是记录运行情况还是定位线上问题&#xff0c;都离不开对日志的分析。日志记录了系统行为的时间、地点、状态等相关信息&#xff0c;能帮助我们了解并监控系统状态&#xff0c;并在发生错误或者接近某种危险状态时能…

emu8086汇编语言输出“Hello World!“

输出Hello world 首先我们尝试用C语言来实现该功能&#xff1a; #include <stdio.h>int main() {printf("Hello World!"); // 输出“Hello World!”return 0; } 将这行代码翻译成汇编语言... ; DS 数据段定义 DATA SEGMENTZIFU DB Hello World!,$ ;字符串…

歌曲《兄弟情深》:歌手荆涛歌曲中的真挚情感

在人生的道路上&#xff0c;有时我们会遇到迷茫、失落、困惑等种种情境。而在这些时刻&#xff0c;身边有一个真挚的兄弟&#xff0c;其意义是无法估量的。歌手荆涛演唱的《兄弟情深》即是对这种深厚情感的美妙歌颂。 一、迷茫时的指引 “当我迷茫时&#xff0c;有你帮目标重新…

安卓系统修图软件(二)

晚上好&#xff0c;自上一次博主分享修图软件之后&#xff0c;今天博主将带来第二期安卓修图软件的推送&#xff0c;个个都是宝藏&#xff0c;建议大家赶紧体验哦。 1.canva可画 如果说有一款手机APP可以与PS媲美&#xff0c;那么一定非canvas莫属。这款强大的修图软件支持海报…

【面试题】介绍一下类加载过程,什么是双亲委派模型

背景 java 文件在运行之前&#xff0c;必须经过编译和类加载两个过程&#xff1a; 编译过程&#xff1a;把 .java 文件 编译成 .class 文件类加载过程&#xff1a;把 .class 文件加载到 JVM 内存里&#xff0c;加载完成后就会得到一个 class 对象&#xff0c;我们就可以使用 n…

将本地项目上传到gitee

本文详细介绍如何将本地项目上传到gitee 1.登录gitee创建一个与本地项目名相同的仓库 2.进入本地项目所在路径&#xff0c;打开Git Bash 3.执行初始化命令 git init4.添加远程仓库 4.1 点击复制你的HTTPS仓库路径 4.2 执行添加远程仓库命令 git remote add origin 你的…

顺序查找(线性查找),折半查找(二分或对分查找),分块查找(索引顺序查找)

文章目录 查找查找的基本概念 线性表的查找一、顺序查找&#xff08;线性查找&#xff09;二、折半查找&#xff08;二分或对分查找&#xff09;三、分块查找&#xff08;索引顺序查找&#xff09; 查找 查找的基本概念 查找表 查找表是同一类型的数据元素&#xff08;或记录…

C#文件操作File类vsFileInfo类和Directory类vsDirectoryInfo类

目录 一、File类vsFileInfo类 1.File类 &#xff08;1&#xff09;示例源码 &#xff08;2&#xff09;生成效果 2.FileInfo类 &#xff08;1&#xff09;示例源码 &#xff08;2&#xff09;生成效果 二、 Directory类vsDirectoryInfo类 1.Directory类 &#xff08;…

怎么在哔哩哔哩上引流?分享五个b站引流推广必备的几个方法

大家好&#xff0c;我是 小刘今天为大家分享的是抖音引流知识分享&#xff0c;今天咱们聊一些干货知识&#xff0c;绝对会让你们有一个重新的认知。哔哩的流量大&#xff0c;是毋庸置疑的&#xff0c;哔哩也是最早一批短视频平台。哔哩于2017年上线&#xff0c;一开始主要是通过…

基于SSM的企业订单跟踪管理系统(有报告)。Javaee项目

演示视频&#xff1a; 基于SSM的企业订单跟踪管理系统&#xff08;有报告&#xff09;。Javaee项目 项目介绍&#xff1a; 采用M&#xff08;model&#xff09;V&#xff08;view&#xff09;C&#xff08;controller&#xff09;三层体系结构&#xff0c;通过Spring SpringM…

Kotlin学习——kt入门合集博客 kt里的委派模式Delegation kt里的特性

Kotlin 是一门现代但已成熟的编程语言&#xff0c;旨在让开发人员更幸福快乐。 它简洁、安全、可与 Java 及其他语言互操作&#xff0c;并提供了多种方式在多个平台间复用代码&#xff0c;以实现高效编程。 https://play.kotlinlang.org/byExample/01_introduction/02_Functio…

2023年【N1叉车司机】新版试题及N1叉车司机作业考试题库

题库来源&#xff1a;安全生产模拟考试一点通公众号小程序 N1叉车司机新版试题参考答案及N1叉车司机考试试题解析是安全生产模拟考试一点通题库老师及N1叉车司机操作证已考过的学员汇总&#xff0c;相对有效帮助N1叉车司机作业考试题库学员顺利通过考试。 1、【多选题】《中华…

基于U-Net的视网膜血管分割(Pytorch完整版)

基于 U-Net 的视网膜血管分割是一种应用深度学习的方法&#xff0c;特别是 U-Net 结构&#xff0c;用于从眼底图像中分割出视网膜血管。U-Net 是一种全卷积神经网络&#xff08;FCN&#xff09;&#xff0c;通常用于图像分割任务。以下是基于 U-Net 的视网膜血管分割的内容&…

公司注册资金认缴的好处有哪些

公司注册资金认缴的好处 1、减少投资项目审批&#xff0c;最大限度地缩小审批、核准、备案范围&#xff0c;切实落实企业和个人投资自主权。对确需审批、核准、备案的项目&#xff0c;要简化程序、限时办结。同时&#xff0c;为避免重复投资和无序竞争&#xff0c;强调要加强土…

LCR 047. 二叉树剪枝 和 leetCode 1110. 删点成林 + 递归 + 图解

给定一个二叉树 根节点 root &#xff0c;树的每个节点的值要么是 0&#xff0c;要么是 1。请剪除该二叉树中所有节点的值为 0 的子树。节点 node 的子树为 node 本身&#xff0c;以及所有 node 的后代。 示例 1: 输入: [1,null,0,0,1] 输出: [1,null,0,null,1] 解释: 只有…