[MyBatisPlus]代码生成器
生活随笔
收集整理的這篇文章主要介紹了
[MyBatisPlus]代码生成器
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
代碼生成器
引入依賴
<dependency><groupId>com.baomidou</groupId><artifactId>mybatis-plus-generator</artifactId><version>3.5.1</version></dependency><dependency><groupId>org.freemarker</groupId><artifactId>freemarker</artifactId><version>2.3.31</version></dependency>快速生成
package com.xxxx.mybatisplus;import com.baomidou.mybatisplus.generator.FastAutoGenerator; import com.baomidou.mybatisplus.generator.config.OutputFile; import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;import java.util.Collections;public class FastAutoGeneratorTest {public static void main(String[] args){FastAutoGenerator.create("jdbc:mysql://localhost:3306/mybatis_plus?serverTimezone=UTC&&characterEncoding=utf-8&useSSL=false", "root", "password").globalConfig(builder -> {builder.author("firetang") // 設置作者.enableSwagger() // 開啟 swagger 模式.fileOverride() // 覆蓋已生成文件.outputDir("D://mybatis_plus"); // 指定輸出目錄}).packageConfig(builder -> {builder.parent("com.xxxx") // 設置父包名.moduleName("mybatisplus") // 設置父包模塊名.pathInfo(Collections.singletonMap(OutputFile.mapperXml, "D://mybatis_plus")); // 設置mapperXml生成路徑}).strategyConfig(builder -> {builder.addInclude("t_user") // 設置需要生成的表名.addTablePrefix("t_", "c_"); // 設置過濾表前綴}).templateEngine(new FreemarkerTemplateEngine()) // 使用Freemarker引擎模板,默認的是Velocity引擎模板.execute();} }總結
以上是生活随笔為你收集整理的[MyBatisPlus]代码生成器的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 早报:vivo X100系列首销金额超1
- 下一篇: [MyBatisPlus]模拟多数据源环