MyBatis-Plus-代码生成器(新)使用方法

编程入门 行业动态 更新时间:2024-10-18 06:11:29

MyBatis-Plus-代码生成器(新)<a href=https://www.elefans.com/category/jswz/34/1769874.html style=使用方法"/>

MyBatis-Plus-代码生成器(新)使用方法

注意:

适用版本:mybatis-plus-generator 3.5.1 及其以上版本,对历史版本不兼容!3.5.1 以下的请参考 代码生成器旧,/

一、导入依赖

		<dependency><groupId>com.baomidou</groupId><artifactId>mybatis-plus-generator</artifactId><version>3.5.1</version></dependency><dependency><groupId>org.freemarker</groupId><artifactId>freemarker</artifactId></dependency><dependency><groupId>com.baomidou</groupId><artifactId>mybatis-plus-extension</artifactId><version>3.4.3</version></dependency>

二、在SpringBoot主启动类的同级目录下新建一个主类


import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;public class PracticeApplication {public static void main(String[] args) {FastAutoGenerator.create("jdbc:mysql://localhost:3306/vueblog", "root", "root").globalConfig(builder -> {builder.author("zyh") // 设置作者.enableSwagger() // 开启 swagger 模式.fileOverride() // 覆盖已生成文件// 指定输出目录.outputDir("C://Code//VueBlog//back//src//main//java"); }).packageConfig(builder -> {builder.parent("com.zhu") // 设置父包名.moduleName("back");// 设置父包模块名// 设置mapperXml生成路径.pathInfo(Collections.singletonMap(OutputFile.mapperXml, "D://"));}).strategyConfig(builder -> {builder.addInclude("zhu_blog","zhu_user") // 设置需要生成的表名.addTablePrefix("zhu_"); // 设置过滤表前缀}).templateEngine(new FreemarkerTemplateEngine()) // 使用Freemarker引擎模板,默认的是Velocity引擎模板.execute();}
}

三、启动此类

这时就会发现项目上新建了四个软件包,如下:

更多推荐

MyBatis-Plus-代码生成器(新)使用方法

本文发布于:2023-07-28 21:54:19,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1330327.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:使用方法   代码生成器   MyBatis

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!