目录
频道首页
使用Mybatis-plus生成springboot项目
收藏
0
xiaoan 最近修改于 2023-07-22 21:49:45
import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.config.OutputFile;

import java.util.Collections;

public class CodeGenerat {
    public static void main(String[] args) {
        generat();
    }

    private static void generat(){
        FastAutoGenerator.create("jdbc:mysql://localhost:3306/db_manage?serverTimezone=UTC", "root", "root")
                .globalConfig(builder -> {
                    builder.author("xiaoan") // 设置作者
                            .enableSwagger() // 开启 swagger 模式
                            .fileOverride() // 覆盖已生成文件
                            .outputDir("D:\\JavaWorkpace\\manage\\src\\main\\java\\"); // 指定输出目录
                })
                .packageConfig(builder -> {
                    builder.parent("com.xiaoan.manage") // 设置父包名
                            .moduleName("") // 设置父包模块名
                            .pathInfo(Collections.singletonMap(OutputFile.mapperXml, "D:\\JavaWorkpace\\manage\\src\\main\\resources\\mapper")); // 设置mapperXml生成路径
                })
                .strategyConfig(builder -> {
                    builder.entityBuilder().enableLombok();
                    builder.mapperBuilder().enableMapperAnnotation().build();
                    builder.controllerBuilder().enableHyphenStyle()  // 开启驼峰转连字符
                            .enableRestStyle();  // 开启生成@RestController 控制器
                    builder.addInclude("t_user") // 设置需要生成的表名
                            .addTablePrefix("t_"); // 设置过滤表前缀
                })
//                .templateEngine(new FreemarkerTemplateEngine()) // 使用Freemarker引擎模板,默认的是Velocity引擎模板
                .execute();
    }
}
内容大纲
批注笔记
使用Mybatis-plus生成springboot项目
ArticleBot
z
z
z
z
主页
会议室
Git管理
文章
云文档
看板