1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
| package cn.sdadgz.common;
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 Generator { public static void main(String[] args) { String outputDir = "D:\\工具\\编程\\idea\\java工作区\\springcloudalibaba\\seata\\src\\main\\java"; String mapperOutputDir = "D:\\工具\\编程\\idea\\java工作区\\springcloudalibaba\\seata\\src\\main\\resources" + "\\mapper"; String packagePath = "cn.sdadgz";
String tableName = "user";
FastAutoGenerator.create("jdbc:mysql://sdadgz.cn:3307/spring-cloud", "root", "123456") .globalConfig(builder -> { builder.author("sdadgz") .enableSwagger() .disableOpenDir() .outputDir(outputDir); }) .packageConfig(builder -> { builder.parent(packagePath) .pathInfo(Collections.singletonMap(OutputFile.xml, mapperOutputDir)); }) .strategyConfig(builder -> { builder.addInclude(tableName) .entityBuilder() .enableLombok() .controllerBuilder() .enableRestStyle() .mapperBuilder() .enableMapperAnnotation(); }) .templateEngine(new FreemarkerTemplateEngine()) .execute(); } }
|