首先先配置pom依赖
这里有一个注意的-----mybatis-plus-generator这个依赖一定要是3.51低于该版本或高于该版本后续生成都会变麻烦
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-generator</artifactId>
<version>3.5.1</version>
</dependency>
配置yml
server:
port: 8080
spring:
application:
name: mybatis-plus-generate # 应用名称
datasource:
username: root
password: 333
#serverTimezone=UTC是欧洲时间与中国时间不同 把时间改为中国时区CTT
url: jdbc:mysql://localhost:3306/gz2130?serverTimezone=CTT&useUnicode=true&characterEncoding=utf8&useSSL=false
String property = System.getProperty("user.dir");
FastAutoGenerator.create(
"jdbc:mysql://localhost:3306/gz2130?serverTimezone=CTT&useUnicode=true&characterEncoding=utf8&useSSL=false",
"root",
"333")
.globalConfig(builder -> {
builder.author("chenhaijian")
.enableSwagger()
.fileOverride()
.outputDir(property+"/src/main/java");
})
.packageConfig(builder -> {
builder.parent("com")
.moduleName("chen")
.pathInfo(Collections.singletonMap(OutputFile.mapperXml, property+"/src/main/resources/mapper"));
})
.strategyConfig(builder -> {
builder.addInclude("user")
.addTablePrefix("t_", "c_");
})
.templateEngine(new FreemarkerTemplateEngine())
.execute();
原来的样子 运行后
|