• sb_mybatis_puls2.3
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.3.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.huarui</groupId>
<artifactId>sb_mybatis_puls2.3</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>sb_mybatis_puls2.3</name>
<description>Demo project for Spring Boot</description> <properties>
<java.version>1.8</java.version>
</properties> <dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency> <dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency> <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency> <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency> <!--mybatis plus 2.3 start-->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>2.3</version>
</dependency>
<!--mybatis plus 2.3 end--> <!-- freemarker 代码生成器模板 start-->
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
</dependency>
<!-- freemarker 代码生成器模板 end--> <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency> </dependencies> <build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build> </project>

pom.xml

server:
port: 8080 #mysql
spring:
datasource:
url: jdbc:mysql://39.108.85.204:3306/mybatis_plus?useUnicode=true&characterEncoding=utf8
username: youxiu326
password: zz123456.ZZ
driver-class-name: com.mysql.cj.jdbc.Driver mybatis-plus:
# 如果是放在src/main/java目录下 classpath:/com/yourpackage/*/mapper/*Mapper.xml
# 如果是放在resource目录 classpath:/mapper/*Mapper.xml
mapper-locations: classpath:/com/huarui/mybatisplus/mapper/*Mapper.xml
#实体扫描,多个package用逗号或者分号分隔
typeAliasesPackage: com.huarui.mybatisplus.entity
global-config:
#主键类型 0:"数据库ID自增", 1:"用户输入ID",2:"全局唯一ID (数字类型唯一ID)", 3:"全局唯一ID UUID";
id-type: 2
#字段策略 0:"忽略判断",1:"非 NULL 判断"),2:"非空判断"
field-strategy: 2
#驼峰下划线转换
db-column-underline: true
#mp2.3+ 全局表前缀 mp_
table-prefix: tal_
#刷新mapper 调试神器
#refresh-mapper: true
#数据库大写下划线转换
capital-mode: true
# Sequence序列接口实现类配置
key-generator: com.baomidou.mybatisplus.incrementer.OracleKeyGenerator
#逻辑删除配置(下面3个配置)
logic-delete-value: -1
logic-not-delete-value: 1
#注入自定义SQL
sql-injector: com.huarui.mybatisplus.configuration.MySqlInjector
#自定义填充策略接口实现
meta-object-handler: com.huarui.mybatisplus.configuration.MyMetaObjectHandler
configuration:
#配置返回数据库(column下划线命名&&返回java实体是驼峰命名),自动匹配无需as(没开启这个,SQL需要写as: select user_id as userId)
map-underscore-to-camel-case: true
cache-enabled: false
#配置JdbcTypeForNull, oracle数据库必须配置
jdbc-type-for-null: 'null'
# 配置slq打印日志
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl

application.yml

/*
Navicat MySQL Data Transfer Source Server : 阿里云
Source Server Version : 50724
Source Host : youxiu326.xin:3306
Source Database : mybatis_plus Target Server Type : MYSQL
Target Server Version : 50724
File Encoding : 65001 Date: 2019-02-17 15:59:52
*/ SET FOREIGN_KEY_CHECKS=0; -- ----------------------------
-- Table structure for tbl_employee
-- ----------------------------
DROP TABLE IF EXISTS `tbl_employee`;
CREATE TABLE `tbl_employee` (
`id` varchar(20) NOT NULL,
`last_name` varchar(50) DEFAULT NULL,
`email` varchar(50) DEFAULT NULL,
`gender` char(1) DEFAULT NULL,
`age` int(11) DEFAULT NULL,
`version` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- ----------------------------
-- Records of tbl_employee
-- ----------------------------
INSERT INTO `tbl_employee` VALUES ('1', '李老师', 'youxiu326@163.com', '1', '35', '1');
INSERT INTO `tbl_employee` VALUES ('1096995791036706818', 'MP', 'mp@atguigu.com', null, null, '1');
INSERT INTO `tbl_employee` VALUES ('1096998099921383425', '宋老师', 'sls@atguigu.com', '1', '35', '1');
INSERT INTO `tbl_employee` VALUES ('1096999885201649665', '玛利亚老师', 'mly@sina.com', '0', '22', null);
INSERT INTO `tbl_employee` VALUES ('1097000111899598849', '玛利亚老师', 'mly@sina.com', '0', '22', null);
INSERT INTO `tbl_employee` VALUES ('2', 'Jerry', 'jerry@atguigu.com', '0', '25', '1');
INSERT INTO `tbl_employee` VALUES ('3', 'TomAA', 'tomAA@sina.com', '1', '22', '3');
INSERT INTO `tbl_employee` VALUES ('4', '苍老师', 'cls@sina.com', '0', '35', '1'); -- ----------------------------
-- Table structure for tbl_user
-- ----------------------------
DROP TABLE IF EXISTS `tbl_user`;
CREATE TABLE `tbl_user` (
`id` varchar(20) NOT NULL,
`name` varchar(50) DEFAULT NULL,
`email` varchar(50) DEFAULT NULL,
`age` int(11) DEFAULT NULL,
`deleteFlag` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- ----------------------------
-- Records of tbl_user
-- ----------------------------
INSERT INTO `tbl_user` VALUES ('1', '小日', 'aaaaaa@.qq.com', '28', '1');
INSERT INTO `tbl_user` VALUES ('2', '小日2', 'aaaaaa@.qq.com', '22', '1');
INSERT INTO `tbl_user` VALUES ('3', '小日3', 'abbbaa@.qq.com', '22', '-1');
INSERT INTO `tbl_user` VALUES ('4', 'youxiu326', 'niubi@.qq.com', '22', null);

mybatis_plus.sql

/**
*
* 代码生成器 2.3版
*
* Created by youxiu326 on 2019/2/17.
*/
public class MpGenerator { public static void main(String[] args) {
//1. 全局配置
GlobalConfig config = new GlobalConfig();
config.setActiveRecord(true) // 是否支持AR模式
.setAuthor("youxiu326@163.com") // 作者
.setOutputDir("D:\\sortware\\IDEA\\package\\sb_mybatis_puls2.3\\src\\main\\java") // 生成路径
.setFileOverride(true) // 文件覆盖
.setEnableCache(false)// XML 二级缓存
.setActiveRecord(true)// 不需要ActiveRecord特性的请改为false
.setIdType(IdType.ID_WORKER) // 主键策略 内容为空自动填充(默认配置)
.setServiceName("%sService") // 设置生成的service接口的名字的首字母是否为I (%s 会自动填充表实体属性)
// IEmployeeService
.setBaseResultMap(true) //是否生成mapper result
.setBaseColumnList(true); //是否生成mapper 查询列 //2. 数据源配置
DataSourceConfig dsConfig = new DataSourceConfig();
dsConfig.setDbType(DbType.MYSQL) // 设置数据库类型
.setDriverName("com.mysql.jdbc.Driver")
.setUrl("jdbc:mysql://39.108.85.204:3306/mybatis_plus?useUnicode=true&characterEncoding=utf8")
.setUsername("youxiu326")
.setPassword("zz123456.ZZ"); //3. 策略配置
StrategyConfig stConfig = new StrategyConfig();
stConfig.setCapitalMode(true) //全局大写命名
.setDbColumnUnderline(true) // 指定表名 字段名是否使用下划线
.setNaming(NamingStrategy.underline_to_camel) // 数据库表映射到实体的命名策略
.setTablePrefix("tbl_")
.setInclude(new String[] { "tbl_user"}); // 生成的表 //4. 包名策略配置
PackageConfig pkConfig = new PackageConfig();
pkConfig.setParent("com.huarui.mybatisplus")
.setMapper("mapper")
.setService("service")
.setController("controller")
.setEntity("entity")
.setXml("mapper"); //5. 整合配置
AutoGenerator ag = new AutoGenerator(); ag.setTemplateEngine(new FreemarkerTemplateEngine())
.setGlobalConfig(config)
.setDataSource(dsConfig)
.setStrategy(stConfig)
.setPackageInfo(pkConfig); //6. 执行
ag.execute();
} }

执行成功后,自动生成 entity mapper service controller

MyBatis Plus 2.3 个人笔记-01-代码生成器的更多相关文章

  1. 软件测试之loadrunner学习笔记-01事务

    loadrunner学习笔记-01事务<转载至网络> 事务又称为Transaction,事务是一个点为了衡量某个action的性能,需要在开始和结束位置插入一个范围,定义这样一个事务. 作 ...

  2. 《30天自制操作系统》笔记(01)——hello bitzhuwei’s OS!

    <30天自制操作系统>笔记(01)——hello bitzhuwei's OS! 最初的OS代码 ; hello-os ; TAB=4 ORG 0x7c00 ; 指明程序的装载地址 ; 以 ...

  3. 《The Linux Command Line》 读书笔记01 基本命令介绍

    <The Linux Command Line> 读书笔记01 基本命令介绍 1. What is the Shell? The Shell is a program that takes ...

  4. PHP 学习笔记 01

    例子: 为什么要学PHP 主观原因: 前段时间在学校处理了毕业的一些事情,回到上海后开始了找工作的旅程.意向工作是WPF开发或者ASP.NET 作为后端的WEB开发. 陆陆续续一直在面试,其中有一家公 ...

  5. 【技能大赛笔记01】Zigbee点对点按键控制程序开发

    [技能大赛笔记01]Zigbee点对点按键控制程序开发 --2017年"物联网物联网技术应用与维护"任务五题1(中职组) 1.题目要求 2.工程文件 在比赛中,提供了一个基于Bas ...

  6. JS自学笔记01

    JS自学笔记01 1.开发工具 webstorm 2.js(javascript) 是一门脚本.解释性.动态类型.基于对象的语言 含三个部分: ECMAScript标准–java基本语法 DOM(Do ...

  7. 《30天自制操作系统》笔记(01)——hello bitzhuwei’s OS!【转】

    转自:http://www.cnblogs.com/bitzhuwei/p/OS-in-30-days-01-hello-bitzhuwei-OS.html 阅读目录(Content) 最初的OS代码 ...

  8. ASP.NET Identity 2集成到MVC5项目--笔记01

    Identiry2是微软推出的Identity的升级版本,较之上一个版本更加易于扩展,总之更好用.如果需要具体细节.网上具体参考Identity2源代码下载 参考文章 在项目中,是不太想直接把这一堆堆 ...

  9. C++ GUI Qt4学习笔记01

    C++ GUI Qt4学习笔记01   qtc++signalmakefile文档平台 这一章介绍了如何把基本的C++只是与Qt所提供的功能组合起来创建一些简单的图形用户界面应用程序. 引入两个重要概 ...

  10. SaToken学习笔记-01

    SaToken学习笔记-01 SaToken版本为1.18 如果有排版方面的错误,请查看:传送门 springboot集成 根据官网步骤maven导入依赖 <dependency> < ...

随机推荐

  1. windev的字符集选择设置及元素命名方法建议

    windev支持多语言,且支持整站翻译,同时支持最终用户的多语言选择,可以说多语言功能已经非常的全面和强大. windev原生支持英语.法语和葡萄牙语,在使用如中文等非拉丁字母语言时,需要在多个地方进 ...

  2. 【01】Maven依赖插件之maven-dependency-plugin

    一.插件目标(goal) 1.analyze:分析项目依赖,确定哪些是已使用已声明的,哪些是已使用未声明的,哪些是未使用已声明的 2.analyze-dep-mgt:分析项目依赖,列出已解析的依赖项与 ...

  3. 怎么查看已安装的office的序列号?ospp.vbs是什么文件

    office2007查看方法:点击开始菜单→控制面板→系统和安全→系统把它往下拉.就可以看到你的序列号.也就是激活码和密匙了office2010查看方法:下载使用Product Key Finder. ...

  4. k8s 中 nfs作为存储的三种方式

    1.安装nfs服务.直接给命令 yum install nfs-utils vim /etc/exports /data/k8s/ 172.16.1.0/24(sync,rw,no_root_squa ...

  5. [USACO20FEB]Equilateral Triangles P 题解

    优雅的暴力. 设三个点为 \((i,j,k)\),则有 \(6\) 个未知数即 \(x_i,x_j,x_k,y_i,y_j,y_k\).又因为有 \(2\) 条关于这 \(6\) 个未知数的方程 \( ...

  6. Linux网卡ifcfg-eth0配置详解

    DEVICE="eth1"                              网卡名称 NM_CONTROLLED="yes"            n ...

  7. table表格的td行利用css显示...

      默认超过指定长度以...显示, 鼠标放到文本上显示全 代码如下 .fh{ max-width:220px; word-wrap:break-word; text-overflow:ellipsis ...

  8. 25 面向对象编程 继承概念 代码 快捷键 super注意点

    继承概念 继承的本质是对某一批的抽象,从而实现对现实世界更美好的建模. extends的意思的"扩展".子类是父类的扩展. JAVA中类只有单继承,没有多继承!理解:一个儿子只能有 ...

  9. LGP5089题解

    考试的一道题,考场上sb了没写出来,然后在两天后的英语课上胡出来了( 首先猜一个奇怪的结论: 对于元素 \((a,b)\),看做连接第 \(a\) 列和第 \(b\) 行的一条边,那么如果一行和一列在 ...

  10. HIve的基本使用

    WHERE从表中筛选行: SELECT从表中查询指定的列: group by在列上做聚合. -- 假设数据文件的内容,字段之间以ASCII 001(ctrl-A)分隔,行之间以换行分隔. CREATE ...