package com.hxzk.gps.util.CodeGenerator;
|
|
import com.baomidou.mybatisplus.generator.FastAutoGenerator;
|
import com.baomidou.mybatisplus.generator.config.OutputFile;
|
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;
|
|
import java.util.Collections;
|
import java.util.HashMap;
|
import java.util.Map;
|
|
public class CodeGenerator {
|
public static void main(String[] args) {
|
// 数据库连接信息
|
String url = "jdbc:mysql://localhost:3306/hxzkuwb?useSSL=false&serverTimezone=Asia/Shanghai";
|
String username = "root";
|
String password = "hxzk20151102";
|
|
// 自定义 mapper.xml 的输出路径
|
Map<OutputFile, String> pathInfo = new HashMap<>();
|
pathInfo.put(OutputFile.xml, "src/main/resources/mapper/ThreeModel");
|
|
FastAutoGenerator.create(url, username, password)
|
.globalConfig(builder -> {
|
// 设置作者
|
builder.author("YuZhiTong")
|
// 禁止覆盖已存在的文件
|
.fileOverride()
|
// 输出目录,这里设置为项目根目录下的 temp 目录,其他文件会生成到该目录下,mapper.xml 会按照自定义路径生成
|
.outputDir("src\\main\\java");
|
})
|
.packageConfig(builder -> {
|
// 设置父包名
|
builder.parent("com.hxzk")
|
// 设置模块名
|
.moduleName("gps")
|
.entity("entity.ThreeModel")
|
.service("service.ThreeModel")
|
.serviceImpl("service.impl.ThreeModel")
|
.mapper("mapper.ThreeModel")
|
// 自定义路径信息
|
.pathInfo(pathInfo);
|
})
|
.strategyConfig(builder -> {
|
// 设置需要生成的表名
|
builder.addInclude(Collections.singletonList("tb_threemodel"))
|
// 设置过滤表前缀
|
.addTablePrefix("t_", "c_");
|
})
|
.templateEngine(new FreemarkerTemplateEngine())
|
.execute();
|
}
|
}
|