Mybatis-Plus学习小项目及详细教程

Mybatis-Plus详解(新建maven项目、查询所有信息、打印SQL日志、实现CRUD(增删改查)、分页、条件查询且分页,前后端分离式开发) MyBatis-Plus(opens new window) (简称MP) 是一个MyBatis(opens new window)的增强工具,在MyBatis的基础上只做增强不做改变,为简化开发、提高效率而生。想查看官网相关内容的化我这里提供了官网地址:https://baomidou.com/ 特点 无侵入:只做增强不做改变,引入它不会对现有工程产生影响,如丝般顺滑 损耗小:启动即会自动注入基本CRUD,性能基本无损耗,直接面向对象操作 强大的CRUD操作:内置通用Mapper、通用Service 阅读详情

Mybatis-Plus学习总结

Mybatis-plus官网:https://baomidou.com/
Mybatis-plus详细教程:https://www.hxstrive.com/subject/mybatis_plus.htm

Mybatis-plus简介

MyBatis-Plus (opens new window)(简称 MP)是一个 MyBatis (opens new window)的增强工具,在 MyBatis 的基础上只做增强不做改变,为简化开发、提高效率而生。

Mybatis-plus项目

  • Spring Boot 2.5.0
  • mybatis-plus 3.4.0
  • Mysql 8.0.25
  • lombok
  • Swagger2 2.9.2
一、准备工作
在创建项目之前,这里首先准备了一张用户信息表 user_info,相应的sql脚本如下:
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

DROP TABLE IF EXISTS `user_info`;
CREATE TABLE `user_info`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
  `available` int(1) NULL DEFAULT 1 COMMENT '是否可用,1 可用,0 不可用',
  `create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
  `deleted` int(1) NULL DEFAULT 0 COMMENT '是否删除,0 未删除, 1 删除',
  `update_time` datetime(0) NULL DEFAULT NULL COMMENT '修改时间',
  `avatar` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '头像',
  `email` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '邮箱',
  `password` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '密码',
  `phone` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '手机号',
  `salt` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '盐',
  `sex` int(1) NULL DEFAULT NULL COMMENT '性别 0未知 1女 2男',
  `user_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '姓名',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 33 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '用户信息表' ROW_FORMAT = Dynamic;

INSERT INTO `user_info` VALUES (1, 1, '2021-05-14 13:30:32', 0, '2021-05-19 15:19:15', NULL, '12345678@qq.com', '123456', '12345678910', '12', 1, '张三');
INSERT INTO `user_info` VALUES (2, 1, '2021-05-14 13:30:32', 0, '2021-05-19 15:19:15', NULL, '12345678@qq.com', '123456', '12345678910', '12', 1, '张三');
INSERT INTO `user_info` VALUES (3, 1, '2021-05-14 13:30:32', 0, '2021-05-19 15:19:15', NULL, '12345678@qq.com', '123456', '12345678910', '12', 1, '张三');
INSERT INTO `user_info` VALUES (4, 1, '2021-05-14 13:30:32', 0, '2021-05-19 15:19:15', NULL, '12345678@qq.com', '123456', '12345678910', '12', 1, '张三');
INSERT INTO `user_info` VALUES (5, 1, '2021-05-14 13:30:32', 0, '2021-05-19 15:19:15', NULL, '12345678@qq.com', '123456', '12345678910', '12', 1, '张三');
INSERT INTO `user_info` VALUES (6, 1, '2021-05-14 13:30:32', 0, '2021-05-19 15:19:15', NULL, '12345678@qq.com', '123456', '12345678910', '12', 1, '张三');
INSERT INTO `user_info` VALUES (7, 1, '2021-05-14 13:30:32', 0, '2021-05-19 15:19:15', NULL, '12345678@qq.com', '123456', '12345678910', '12', 1, '张三');
INSERT INTO `user_info` VALUES (8, 1, '2021-05-14 13:30:32', 0, '2021-05-19 15:19:15', NULL, '12345678@qq.com', '123456', '12345678910', '12', 1, '张三');
INSERT INTO `user_info` VALUES (9, 1, '2021-05-14 13:30:32', 0, '2021-05-19 15:19:15', NULL, '12345678@qq.com', '123456', '12345678910', '12', 1, '张三');
INSERT INTO `user_info` VALUES (10, 1, '2021-05-14 13:30:32', 0, '2021-05-19 15:19:15', NULL, '12345678@qq.com', '123456', '12345678910', '12', 1, '张三');

SET FOREIGN_KEY_CHECKS = 1;

二、创建一个Spring Boot项目

在这里插入图片描述

三、添加所需依赖

在项目的pom.xml文件中添加如下依赖

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

  <!--引入mysql-->
    <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>8.0.25</version>
    </dependency>

    <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
    </dependency>

    <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger2</artifactId>
            <version>2.9.2</version>
    </dependency>
四、在项目的application.yml配置文件中,配置如下信息
spring:
  application:
    name: mybatis-plus
  datasource:
    url: jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&failOverReadOnly=false
    driver-class-name: com.mysql.cj.jdbc.Driver
    username: root
    password: 123456

logging:
  level:
    com:
      example:
        mybatisplus:
          mapper: trace
    root: warn
  pattern:
    console: '%p%m%n'
mybatis-plus:
  configuration:
    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl

注:新建的项目默认配置文件是application.properties,在这里习惯使用yml文件格式。

.yml文件与.properties文件相互转化工具:https://www.toyaml.com/index.html

五、创建实体类
BaseEntity.java

@Data
@AllArgsConstructor
@NoArgsConstructor
public abstract class BaseEntity implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "主键")
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    @ApiModelProperty(value = "是否删除,0 未删除, 1 删除")
    @TableLogic(value = "0",delval = "1")
    @TableField(value = "deleted", fill = FieldFill.INSERT)
    private Integer deleted;

    @ApiModelProperty(value = "是否可用,1 可用,0 不可用")
    @TableField(value = "available", fill = FieldFill.INSERT)
    private Integer available;

    @ApiModelProperty(value = "创建时间")
    @TableField(value = "create_time", fill = FieldFill.INSERT)
    private Date createTime;

    @ApiModelProperty(value = "修改时间")
    @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
    private Date updateTime;
UserInfo.java
@Data
@AllArgsConstructor
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("user_info")   //定义表名
@ApiModel(value="UserInfo对象", description="用户信息表")
public class UserInfo extends BaseEntity {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "头像")
    @TableField("avatar")
    private String avatar;

    @ApiModelProperty(value = "邮箱")
    @TableField("email")
    private String email;

    @ApiModelProperty(value = "密码")
    @TableField("password")
    private String password;

    @ApiModelProperty(value = "手机号")
    @TableField("phone")
    private String phone;

    @ApiModelProperty(value = "盐")
    @TableField("salt")
    private String salt;

    @ApiModelProperty(value = "性别 0未知 1女 2男")
    @TableField("sex")
    private Integer sex;

    @ApiModelProperty(value = "姓名")
    @TableField("user_name")
    private String userName;
}

六、创建mapper接口
UserInfoMapper.java
public interface UserInfoMapper extends BaseMapper<UserInfo> {

}

可以明显看到,上面代码中没有自定义任何自己的方法,所有方法均从 BaseMapper 父接口继承而来。

七、添加mapper接口扫描路径配置
使用 @MapperScan 注解 在Spring Boot的启动类添加mapper接口的扫描路径配置,扫描 com.example.mybatisplus.mapper 包下面的所有 mapper!!!
@SpringBootApplication
@MapperScan("com.example.mybatisplus.mapper")
public class MybatisplusApplication {

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

八、编写一个简单Controller

编写一个简单的controller,使用@Autowired 注解自动注入自定义的 mapper

UserInfoController.java
@RestController
@RequestMapping("/api/userInfo")
@Api(value = "/api/userInfo", tags = {"用户信息表接口"})
public class UserInfoController {

    @Autowired
    private UserInfoMapper userInfoMapper;

    @GetMapping
    public  List  findAllUserList(){
        List<UserInfo> list = userInfoMapper.selectList(null);
        return list;
    }
}
九、启动项目,进行简单测试

在这里插入图片描述
关于更多Mybatis-plus详细知识:

  • BaseMapper 接口 CRUD
  • Service CRUD 接口
  • 条件构造器
  • 常用注解
  • 代码生成器

可以查看https://www.hxstrive.com/subject/mybatis_plus.htm
这里将不对每个知识点进行演示啦!!!

代码生成器

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

代码演示
注:下面代码示例基于上面项目,所有代码在generator包下面。此外需要添加下面的依赖。

一、添加依赖
    <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-generator</artifactId>
            <version>3.4.0</version>
   </dependency>
    <dependency>
            <groupId>org.freemarker</groupId>
            <artifactId>freemarker</artifactId>
            <version>2.3.31</version>
    </dependency>
二、编写工具类

Config.java

package com.example.generator.config;
/**
 * @Author: 
 * @Description:
 * @CreateDate: 2021-05-25 14:49
 * @Version: 1.0
 */

public class Config {
    public static String URL = "jdbc:mysql://127.0.0.1:3306/hang?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&failOverReadOnly=false&zeroDateTimeBehavior=convertToNull&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true";
    public static String USERNAME = "root";
    public static String PASSWORD = "123456";
    public static String DRIVER = "com.mysql.cj.jdbc.Driver";
    public static String TABLE_NAME = "sys_user,sys_role,sys_file";  //多个表明用,连接

    /**
     * 包名
     */
    public static final String PACKAGE_PARENT = "com.example";

    /**
     * 文件名后缀:Dao
     */
    public static final String FILE_NAME_DAO = "%sMapper";

    /**
     * 文件名后缀:MapperXml
     */
    public static final String FILE_NAME_XML = "%sMapper";

    /**
     * MP开头,Service结尾
     */
    public static final String FILE_NAME_SERVICE = "%sService";

    /**
     * 文件名后缀:ServiceImpl
     */
    public static final String FILE_NAME_SERVICE_IMPL = "%sServiceImpl";

    /**
     * 文件名后缀:Controller
     */
    public static final String FILE_NAME_CONTROLLER = "%sController";

    /**
     * 逻辑删除字段
     */
    public static final String FIELD_LOGIC_DELETE_NAME = "deleted";

    /**
     * 作者
     */
    public static final String AUTHOR = "generator";

    /**
     * 生成文件的输出目录
     */
//    public static String projectPath = System.getProperty("user.dir") + "/mp-generator";
    public static String projectPath = System.getProperty("user.dir");

    /**
     * 输出目录
     */
    public static final String outputDir = projectPath + "/src/main/java";

    /**
     * 模板引擎。velocity / freemarker / beetl
     */
    public static final String TEMPLATE_ENGINE = "freemarker";

    /**
     * 是否支持Swagger,默认不支持
     */
    public static final Boolean SWAGGER_SUPPORT = true;

}

CommonUtils.java

package com.example.generator.utils;
import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.core.toolkit.StringPool;
import com.baomidou.mybatisplus.generator.AutoGenerator;
import com.baomidou.mybatisplus.generator.InjectionConfig;
import com.baomidou.mybatisplus.generator.config.*;
import com.baomidou.mybatisplus.generator.config.po.TableInfo;
import com.baomidou.mybatisplus.generator.config.rules.DateType;
import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
import com.baomidou.mybatisplus.generator.engine.AbstractTemplateEngine;
import com.baomidou.mybatisplus.generator.engine.BeetlTemplateEngine;
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;
import com.baomidou.mybatisplus.generator.engine.VelocityTemplateEngine;
import com.example.generator.config.Config;
import java.util.ArrayList;
import java.util.List;

/**
 * @Author:
 * @Description:
 * @CreateDate: 2021-05-25 14:50
 * @Version: 1.0
 */

public class CommonUtils {

    // 配置
    private static GlobalConfig globalConfig() {
        return new GlobalConfig()
                .setAuthor(Config.AUTHOR)           //作者名称
                .setOutputDir(Config.outputDir)
                .setFileOverride(true)            //是否覆盖已有文件
                .setOpen(false)                  // 是否打开输出目录
                .setDateType(DateType.ONLY_DATE) // 时间采用java 8,(操作工具类:JavaLib => DateTimeUtils)
                .setEnableCache(false)// XML 二级缓存
                .setBaseResultMap(false)// XML ResultMap
                .setBaseColumnList(false)// XML columList
                .setKotlin(false) //是否生成 kotlin 代码
                .setMapperName(Config.FILE_NAME_DAO) //自定义文件命名,注意 %s 会自动填充表实体属性!
                .setXmlName(Config.FILE_NAME_XML)
                .setServiceName(Config.FILE_NAME_SERVICE)
                .setServiceImplName(Config.FILE_NAME_SERVICE_IMPL)
                .setControllerName(Config.FILE_NAME_CONTROLLER)
                .setSwagger2(Config.SWAGGER_SUPPORT) // model swagger2
                ;
    }

    //数据源配置
    private static DataSourceConfig dataSourceConfig() {
        return new DataSourceConfig()
                .setDbType(DbType.MYSQL)
                .setUrl(Config.URL)
                .setUsername(Config.USERNAME)
                .setPassword(Config.PASSWORD)
                .setDriverName(Config.DRIVER)
                ;
    }

    // 包信息配置
    private static PackageConfig packageConfig() {
        return new PackageConfig()
                .setModuleName("code")
                .setParent(Config.PACKAGE_PARENT)
//                .setController(Config.PACKAGE_NAME_CONTROLLER)
//                .setEntity(Config.PACKAGE_NAME_MODEL)
//                .setMapper(Config.PACKAGE_NAME_DAO)
//                .setXml(Config.PACKAGE_NAME_XML)
//                .setService(Config.PACKAGE_NAME_SERVICE)
//                .setServiceImpl(Config.PACKAGE_NAME_SERVICE_IMPL)
                ;
    }

    //实体类配置
    private static StrategyConfig strategyConfig() {
        return new StrategyConfig()
                .setChainModel(true) // 【实体】是否为构建者模型(默认 false)
                .setNaming(NamingStrategy.underline_to_camel)
                .setColumnNaming(NamingStrategy.underline_to_camel)
//                .setSuperEntityClass(BaseEntity.class)
                .setEntityLombokModel(true)
                .setRestControllerStyle(true)
                .setInclude(Config.TABLE_NAME.split(","))      //数据库表名字
                .setControllerMappingHyphenStyle(false)
                .setEntityTableFieldAnnotationEnable(true) //是否生成实体时,生成字段注解,包括@TableName("")
                ;
    }


    private static InjectionConfig injectionConfig() {
        InjectionConfig injectionConfig = new InjectionConfig() {
            @Override
            public void initMap() {
                // to do nothing
            }
        };
        String templatePath = "/templates/mapper.xml.ftl";
        // 如果模板引擎是 velocity
        // String templatePath = "/templates/mapper.xml.vm";

        // 自定义输出配置
        List<FileOutConfig> focList = new ArrayList<>();
        // 自定义配置会被优先输出
        focList.add(new FileOutConfig(templatePath) {
            @Override
            public String outputFile(TableInfo tableInfo) {
                // 自定义输出文件名 , 如果你 Entity 设置了前后缀、此处注意 xml 的名称会跟着发生变化!!
                return Config.projectPath + "/src/main/resources/mapper/" + tableInfo.getEntityName() + "Mapper" + StringPool.DOT_XML;
            }
        });
        injectionConfig.setFileOutConfigList(focList);
        return injectionConfig;
    }

    // 获取模板引擎——使用freemarker模板引擎
    private static AbstractTemplateEngine getTemplateEngine() {
        String templateEngine = Config.TEMPLATE_ENGINE;
        switch (templateEngine) {
            case "velocity":
                return new VelocityTemplateEngine();
            case "freemarker":
                return new FreemarkerTemplateEngine();
            case "beetl":
                return new BeetlTemplateEngine();
            default:
                return new VelocityTemplateEngine();
        }
    }




    private static TemplateConfig templateConfig() {
        TemplateConfig templateConfig = new TemplateConfig();
        //配置自定义输出模板,指定自定义模板路径,注意不要带上.ftl/.vm, 会根据使用的模板引擎自动识别
        templateConfig.setController("templates/controllerGenerator.java");
        templateConfig.setServiceImpl("templates/serviceImplGenerator.java");
        templateConfig.setMapper("templates/mapperGenerator.java");
        templateConfig.setEntity("templates/entityGenerator.java");
        templateConfig.setXml(null);
        return templateConfig;

    }



    // 执行器
    public static void execute() {
        GlobalConfig globalConfig = globalConfig();
        DataSourceConfig dataSourceConfig = dataSourceConfig();
        PackageConfig packageConfig = packageConfig();
        StrategyConfig strategyConfig = strategyConfig();
        InjectionConfig injectionConfig = injectionConfig();
        AbstractTemplateEngine templateEngine = getTemplateEngine();
        TemplateConfig  templateConfig = templateConfig();
        new AutoGenerator()
                .setGlobalConfig(globalConfig)
                .setDataSource(dataSourceConfig)
                .setStrategy(strategyConfig)
                .setPackageInfo(packageConfig)
                .setTemplateEngine(templateEngine)
                .setCfg(injectionConfig)
                .setTemplate(templateConfig)
                .execute();
    }

}
三、编写生成器模板

自定义代码生成器模板
在项目的resources/templates文件夹下面创建以下模板文件:

controllerGenerator.java.ftl

package ${package.Controller};
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RequestMapping;
<#if restControllerStyle>
import org.springframework.web.bind.annotation.RestController;
<#else>
import org.springframework.stereotype.Controller;
</#if>
<#if superControllerClassPackage??>
import ${superControllerClassPackage};
</#if>

/**
*
* @author ${author}
* @since ${date}
*/
<#if restControllerStyle>
@RestController
<#else>
@Controller
</#if>
@RequestMapping("/api/mp-generator<#if package.ModuleName?? && package.ModuleName != "">/${package.ModuleName}</#if>/<#if controllerMappingHyphenStyle??>${controllerMappingHyphen}<#else>${table.entityPath}</#if>")
@Api(value = "/api/mp-generator<#if package.ModuleName?? && package.ModuleName != "">/${package.ModuleName}</#if>/<#if controllerMappingHyphenStyle??>${controllerMappingHyphen}<#else>${table.entityPath}</#if>", tags = {"${table.comment!}接口"})
<#if kotlin>
class ${table.controllerName}<#if superControllerClass??> : ${superControllerClass}()</#if>
<#else>
    <#if superControllerClass??>
public class ${table.controllerName} extends ${superControllerClass} {
    <#else>
public class ${table.controllerName} {
    </#if>

}
</#if>

serviceImplGenerator.java.ftl

package ${package.ServiceImpl};
import ${package.Entity}.${entity};
import ${package.Mapper}.${table.mapperName};
import ${package.Service}.${table.serviceName};
import ${superServiceImplClassPackage};
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
*
* @author ${author}
* @since ${date}
*/
@Slf4j
@Service
<#if kotlin>
open class ${table.serviceImplName} : ${superServiceImplClass}<${table.mapperName}, ${entity}>(), ${table.serviceName} {

}
<#else>
public class ${table.serviceImplName} extends ${superServiceImplClass}<${table.mapperName}, ${entity}> implements ${table.serviceName} {

}
</#if>

mapperGenerator.java.ftl

package ${package.Mapper};
import ${package.Entity}.${entity};
import ${superMapperClassPackage};
import org.springframework.stereotype.Repository;

/**
*
* @author ${author}
* @since ${date}
*/
@Repository
<#if kotlin>
interface ${table.mapperName} : ${superMapperClass}<${entity}>
<#else>
public interface ${table.mapperName} extends ${superMapperClass}<${entity}> {

}
</#if>

entityGenerator.java.ftl

package ${package.Entity};
import lombok.*;
import java.io.Serializable;
/**
*
* @author ${author}
* @since ${date}
*/
@Data
@EqualsAndHashCode(callSuper = false)
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class ${entity} implements Serializable {
private static final long serialVersionUID = 1L;
<#-- ----------  BEGIN 字段循环遍历  ---------->
<#list table.fields as field>
    private ${field.propertyType} ${field.propertyName};
</#list>
<#-------------- END 字段循环遍历 --------------->
}
四、测试

CodeGenerator.java

package com.example.generator;
import com.example.generator.utils.CommonUtils;
/**
 * @Author:
 * @Description:
 * @CreateDate: 2021-05-25 14:53
 * @Version: 1.0
 * *******************************************
 * 注:生成代码之前根据需要作以下修改:
 * (1)config.Config.java  类中的数据库连接信息
 * (2)config.Config.java  类中包名   PACKAGE_PARENT
 * (3)config.Config.java  类中 TABLE_NAME  数据库表名,多个表明用,连接
 */
public class CodeGenerator {
    public static void main(String[] args) {
        //生成代码,执行此方法
        CommonUtils.execute();
    }
}

执行上面main方法即可生成!!!
在这里插入图片描述
生成后的文件结构
在这里插入图片描述


本篇文章到这里就基本结束了,如果这篇文章对你有帮助,希望大家能留下你的点赞、 关注、 分享、 留言❤️❤️❤️

最后的最后,附上源码下载地址:https://gitee.com/wst-taoge/mybatisplus
在这里插入图片描述

学习 | 超友好的mybatis-plus详细使用教程 前言 好久没更新了,最近在从一个学生转变成一个程序员的过渡中,不幸的是刚准备实习就遇上了就业大寒冬,幸运的是,终于找到一份喜欢的工作—java开发实习生。 可能是行情不好吧,现在大多数公司希望招进来的人能直接干活,和我想象中不一样,没有悠闲的培训,没有划水,反而一上班就有开发工作了。应技术大佬的要求,公司使用的框架是spring cloud alibaba,还用到了mybatis-plus,在恶补之后,也分享给大家。 ... 阅读详情

相关推荐

ASP.NET进销存管理系统源码

开发环境:vs2008+sql2005+控件DXperience v2008-控件 业务管理 客户订单,物料需求计划,采购订单,采购入库单,其他入库单,生产领料计划, 领料单,半成品入库单,销售出库单,其他出库单,退料单,退料入库单,超领单, 委外加工入库单,委外加工出库单,报废单,付款单,收款单,调拨单,期初入库单 报表管理 退料单明细报表,采购入库统计报表,采购入库明细报表,半成品入库统计报表 包成品入库明细报表,委外加工入库统计报表,委外加工入库明细报表,委外加工出库统计报表 委外加工出库明细报表,退料入库统计报表,退料入库明细报表,其他出库单统计报表, 其他出库单明细报表,报废单统计报表,其他入库单统计报表,其他入库单明细报表 基础数据管理 物料数据,BOM,部门,员工,供应商,客户,辅助数据,修改物料编号 系统管理 操作员管理,操作员授权,修改密码,注销,系统备份,系统操作日志 文件管理 文件管理,文件查看,文件入库,文件申请,文件更改单,文件资料一览报表,文件发放统计报表 设备管理 设备基础资料维护,计量器具周检单,模具修复申请单,模具/设备转移单,设备器具报废申请单

MyBatis-Plus详解

MyBatis-Plus (opens new window)(简称 MP)是一个 MyBatis (opens new window)的增强工具,在 MyBatis 的基础上只做增强不做改变,为简化开发、提高效率而生。

chat_bot的博客 1万+

ASP.NET ERP电商进销存系统源码.rar

ASP.NET ERP电商进销存系统源码参考,欢迎下载

Spring boot 入门教程-集成Mybatis-Plus,Java开发究竟该如何学习

lombok provided org.apache.commons commons-lang3 3.7 org.springframework.boot spring-boot-starter-test test org.freemarker freemarker 2.3.28 org.apache.velocity velocity-engine-core 2.0 com.alibaba druid 1.0.9 org.codehaus.jackson jackson-mapp

m0_64867152的博客 162

基于ASP.net的三层框架的进销存管理系统(源码+数据库).zip

功能介绍 1、公开信息:最新商品、物品搜索、系统通知、服务中心、密码设置、发货查询。 2、管理流程:管理问题件、配送发货、记录客户、商品拍照、仓库库存情况、商品分布情况 管理销售退货、管理销售发货、管理销售订单、管理库存盘点、管理出库单、管理入库单、 管理库存调拨、管理采购退货订单、管理采购付款订单、管理采购收货订单、管理采购订单。 3、销售开单:销售发货、销售退货、销售订单、销售开单。 4、库存开单:仓库盘点、仓库调拨、物品入库、物品出库。 5、采购开单:采购退货、采购付款、采购收货、采购订单。 6、系统设置:财务帐号设置、库房管理、服务类型、配送方式管理、通知公告、销售平台管理、 系统日志、仓库设置、网店设置、供应商、商品资料、商品品牌、商品类型、用户类型、管理群组、 默认数据库连接字符串在webconfig配置文件中修改。

C#ASP.NET网络进销存管理系统源码数据库 SQL2008源码类型 WebForm

ASP.NET网络进销存管理系统源码 内含一些新技术的使用,使用的是VS .NET 2008平台采用标准的三层架构设计,采用流行的AJAX技术 使操作更加流畅,统计报表使用FLASH插件美观大方专业。适合二次开发类似项目使用,可以节省您 开发项目周期,源码统计报表部分需要自己将正常功能注释掉的源码手工取消掉注释。这是我在调试程 序时留下的。也是上传源码前的疏忽。 您下载后可以用VS2008直接打开将注释取消掉即可正常使用。 技术特点:1、采用目前最流行的.net技术实现。2、采用B/S架构,三层无限量客户端。 3、配合SQLServer2005数据库支持 4、可实现跨越地域和城市间的系统应用。 5、二级审批机制,简单快速准确。 6、销售功能手写AJAX无刷新,快速稳定。 7、统计报表采用Flash插件美观大方。8、模板式开发,能够快速进行二次开发。权限、程序页面、 基础资料部分通过后台数据库直接维护,可单独拿出继续开发其他系统 9、数据字典,模块架构图,登录页面和主页的logo图片 分别放在DOC PSD 文件夹中

Mybatis-plus之案例教程学习记录

文章目录一、Mybaits-plus简介二、特性MyBatisPlus入门案列一、创建并初始化数据库1、创建数据库:2、创建 User 表二、初始化工程三、添加依赖1、引入依赖2、idea中安装lombok插件四、配置五、编写代码1、主类2、实体3、mapper六、开始使用七、配置日志 一、Mybaits-plus简介 官网:http://mp.baomidou.com/ 参考教程:http://mp.baomidou.com/guide/ MyBatis-Plus(简称 MP)是一个 MyBatis 的增

Liugx的博客 1447

从FPGA/ASIC工程师视角看DDR:手把手拆解Memory Controller、PHY与DRAM芯片的协作流程

本文从FPGA/ASIC工程师视角深入解析DDR内存子系统,详细拆解Memory Controller、PHY与DRAM芯片的协作流程。通过系统架构分解、接口标准解析和实战调试技巧,帮助工程师优化DDR性能并解决常见问题,涵盖地址映射、命令调度、时序校准等关键技术要点。

weixin_42548888的博客 461

MyBatis-Plus学习基本教程!

Mybatis-plus基础学习教程,囊括开发常用功能!

Aubrey5的博客 2648

Windows系统下AutoDock 4.2.6安装避坑指南(附MGLTools配置技巧)

本文详细介绍了在Windows系统下安装和配置AutoDock 4.2.6的完整流程,特别针对分子对接研究中常见的软件安装问题提供了解决方案。从环境准备、分步安装到常见报错处理,涵盖MGLTools配置技巧、工作目录设置和环境变量优化,帮助科研人员快速搭建稳定的分子对接平台。

weixin_29234239的博客 317

oscp备考,oscp系列——Djinn3靶场:ssti漏洞,pkexec提权

oscp备考,oscp系列——Djinn3靶场:ssti漏洞,pkexec提权难度简单偏上对于低权限shell获取涉及:ssti漏洞对于提权:pkexec提权。

2202_75361164的博客 638

MyBatis-Plus 实战教程 同原b站视频的MarkDown笔记

Mybatis-Plus 实战教程

Ctrl_kun的博客 150

EV1527 vs HS1527:固定码芯片的STM32解码避坑指南

本文深入解析EV1527与HS1527固定码芯片的技术差异,提供基于STM32的完整解码方案与稳定性优化策略。通过硬件接口配置、状态机实现及示波器诊断,解决工业遥控、安防报警等场景中的解码难题,特别针对时序差异和干扰问题给出实用解决方案。

o0p1q2r3的博客 339

一个使用 SpringBoot+Vue+Mybatis-Plus 开发的前后端分离个人博客,有配套开发教程,欢迎来学习!

文章目录简介技术路线效果展示前台页面后台博客管理前端页面项目部署配套教程 简介 这是一个使用 SpringBoot+Vue+Mybatis-Plus 开发的前后端分离个人博客,有配套开发教程,欢迎star学习! 技术路线 SpringBoot Vue Mybatis-Plus SpringSecurity MySQL … 效果展示 前台页面 博客首页 分类专栏 标签 留言板 友链 搜索 后台博客管理前端页面 写博客 文章管理 分类管理 标签管

x-dragon8899的博客 4591

避开RK3588开发板SDIO配置的坑:O9201SB WiFi模组接入实战指南

本文为嵌入式开发者提供了在RK3588开发板上,利用TF卡槽接入O9201SB WiFi6模组的实战指南。文章深度剖析了SDIO配置中常见的电源管理序列冲突问题,并给出了从设备树节点修改、内核编译到系统验证的完整解决方案,帮助开发者避开配置陷阱,成功实现高性能无线连接。

sprite的博客 956

YOLO12涨点改进| 损失函数改进篇 |AAAI 2025| 一种小目标检测SDLoss损失函数,解决现有损失函数对不同目标尺度敏感度不足的局限,提高了网络检测不同尺度目标的敏感能力,助力高效涨点

本文提出了一种改进的小目标检测方法SDLoss,通过动态调整尺度损失与位置损失的权重,优化了YOLOv12模型的性能。针对红外小目标检测中存在的两个主要问题:1)标准卷积难以捕捉目标的高斯空间分布特性;2)现有损失函数对不同尺度目标的敏感度不足,研究团队开发了Pinwheel-shaped卷积(PConv)和Scale-based Dynamic损失函数(SDLoss)。PConv通过不对称卷积核设计显著提升感受野,SDLoss则根据目标大小动态平衡尺度与位置损失的影响。

Ai缝合怪、助力小伙伴高效发论文 249

史上最全的mybatis-plus视频教程(含文档和代码)

史上最全的mybatis-plus视频教程(含文档和代码) 史上最全 mybatis-plus课程课程资料(含视频和文档) 链接:https://pan.baidu.com/s/1GD7ropNVffgdlpaiFAhGlA 提取码:eo6z

qq_42097051的博客 661

【例2840】set wcs to current view 将当前视图设置为WCS

set wcs to current view 将当前视图设置为WCS》这是一个NX二次开发官方小例子,下面是代码和解析。相较于混乱、未经验证的代码,官方案例能够确保开发者获得准确的开发方法,这些官方示例代码经过严格测试,能够正确地反映出NX软件的功能和API使用方式,有助于开发者系统地掌握NX二次开发技能,提高开发质量和效率。本专栏订阅后是永久阅读的。欢迎一起学习NX二次开发案例,逐步积累宝贵的经验,早日成为行业专家。

王牌飞行员_里海的博客 491

工作中能用到Mybatis-plus吗?怎么用?

MyBatis-Plus(简称 MP)是一个 MyBatis 的增强工具,在 MyBatis 的基础上只做增强不做改变,为简化开发、提高效率而生。

Ahahaha___的博客 1533

36、真核生物RNA PolII启动子预测相关研究

本文综述了真核生物RNA聚合酶II启动子预测的研究进展,涵盖转录调控机制、核心启动子元件(如TATA框、INR、GC框)、转录因子结合位点预测的挑战与方法。介绍了基于权重矩阵、神经网络和隐马尔可夫模型等多种启动子预测算法,并探讨了启动子分类策略及评分加权方法。通过Hertz-Stormo-Hartzell流程和基因微阵列分析实例,展示了如何识别保守调控序列。文章还总结了当前预测技术的局限性,提出了整合多组学数据、开发深度学习模型、加强实验验证等未来研究方向,旨在提升启动子识别的准确性与生物学意义。

palm99的专栏 192

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

mybatis升级为mybatis-plus实现方案

1.背景 老项目是mybatis的,但是新项目想使用mybatis-plus, 故需要升级 2.实现步骤 步骤一:删除mybatis相关的依赖包 步骤二:导入mybatis-plus相关的包 <!-- https://mvnrepository.com/artifact/com.baomidou/mybatis-plus-boot-starter --> <dependency> <groupId>com.baomidou</groupId&g..

zhishidi的博客 7271

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

Mybatis-plus使用教程

Mybatis-plus使用教程 1.概述。 首先,需要看mybatis-plus的官方文档可以点击此处:mybatis-plus官方文档 mybatis-plus是mybatis的升级版,比它更强大!在 MyBatis 的基础上只做增强不做改变,为简化开发、提高效率而生。 首先看下官方给他的描述吧! 无侵入:只做增强不做改变,引入它不会对现有工程产生影响,如丝般顺滑 损耗小:启动即会自动注入基本 CURD,性能基本无损耗,直接面向对象操作 强大的 CRUD 操作:内置通用 Mapper、通用 Servic

weixin_46295656的博客 1万+

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

【mybatis-plus-join】开源下载和安装教程

【mybatis-plus-join】开源下载和安装教程 【免费下载链接】mybatis-plus-join mybatis plus的多表插件 项目地址: https://gitcode.com/mahuibo123/mybat...

gitblog_01417的博客 288

mybatis-plus保姆级入门教程,轻松实现增删改查

一、前言 通过前几期的基础教学,想必大家都已经掌握springboot项目的创建及项目启动等基本内容了吧(如果还没掌握,请去复习我上几期的内容,好伐?)。 今个儿我要来整点高级的,使用组件的方式来轻松实现数据库交互,大家想不想学?好的,看到大家的积极性如日中天啊,老夫深感欣慰。那bug菌将不遗余力地传授给大家,同时也希望大家在学习的过程中,打好基础,认真听哦。 上一期我们是通过注入jdbc模板类进行数据库查询对吧,虽然这种交互方式可以,但是面对不常用数据类型,就不好使了,所以我要教大家一种最

aa119101的博客 586

学习Mybatis-Plus一篇就够了?超详细讲解?入门,看完这一篇就够了?

现在开始了解和学习Mybatis-Plus的,应该把SSM框架学完了,或者开始了解和学习Spring Boot了吧 应该知道 官方文档 这个东西吧 Mybatis-Plus官网地址: https://baomidou.com/ 最近不是太了解MP,在B站上看Mybatis-Plus的视频教程,并且看看着别人写的博客什么的,在弹幕和评论区老是能看到这个已经过时了,然后我就开始了解新的注解什么的… 后来发现 Mybatis-Plus 的官网,有专业的中文翻译,讲解够详细,旧的新的都有讲到,学到个阶段的学生有

记录学习的历程 228
上一篇: 【问题】Cause: java.sql.SQLException: 不支持的字符集 (在类路径中添加 orai18n.jar): ZHS16GBK
下一篇: 服务器项目部署总结(超详细)
程序猿全栈Lion
博客等级 码龄8年 3097粉丝 249原创
评论 2
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

程序猿全栈Lion

“是一种鼓励,你懂的”

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值