必要依赖
com.baomidou
mybatis-plus-generator
3.5.2
org.apache.velocity
velocity
1.7
代码
FastAutoGenerator.create("url", "username", "password")
.globalConfig(builder -> {
builder.author("baomidou") // 设置作者
.enableSwagger() // 开启 swagger 模式,没有就不要这一项
.fileOverride() // 覆盖已生成文件
.outputDir("D://"); // 指定输出目录,项目的顶级目录
})
.packageConfig(builder -> {
builder.parent("com.baomidou.mybatisplus.samples.generator") // 设置父包名,Application.class的上一级目录
.moduleName("system") // 设置父包模块名,没有就设置为空("")
.pathInfo(Collections.singletonMap(OutputFile.mapperXml, "D://")); // 设置mapperXml生成路径
})
.strategyConfig(builder -> {
builder.addInclude("t_simple") // 设置需要生成的表名
.addTablePrefix("t_", "c_"); // 设置过滤表前缀,过滤之后生成的类名不再拼接t_
})
//.templateEngine(new FreemarkerTemplateEngine()) // 使用Freemarker引擎模板,默认的是Velocity引擎模板
.execute();