package com.sfj.generator.plus;
import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;
public class CodeGenerator {
public static final String author = "wzy";
public static final String url = "jdbc:mysql://localhost:3306/oa_1220?characterEncoding=utf-8&useSSL=false&serverTimezone=Hongkong";
public static final String username = "root";
public static final String password = "root";
public static final String include = "oa_customer_pool";
public static final String table_prefix = "oa_";
public static final String parent = "com.yitu.oa";
public static final String entity = "entity.entity";
public static final String mapper = "mapper";
public static final String xml = "mapper.impl";
public static final String service = "service";
public static final String controller = "controller";
public static void main(String[] args) {
generate();
}
public static void generate() {
FastAutoGenerator.create(url, username, password).globalConfig(builder -> {
builder.author(author)
.enableSwagger()
.fileOverride()
.disableOpenDir()
.outputDir(System.getProperty("user.dir") + "/file");
}).packageConfig(builder -> {
builder.parent(parent)
.entity(entity).mapper(mapper).xml(xml).service(service).controller(controller);
}).strategyConfig(builder -> {
builder.addInclude(include)
.addTablePrefix(table_prefix)
.addFieldPrefix("f_").entityBuilder().enableLombok()
.enableChainModel()
.serviceBuilder().formatServiceImplFileName("%sServiceImp").formatServiceFileName("%sService")
.controllerBuilder().enableRestStyle();
}).templateEngine(new FreemarkerTemplateEngine())
.execute();
}
}
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus</artifactId>
<version>3.5.3</version>
</dependency>
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
<version>2.3.30</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-generator</artifactId>
<version>3.5.3</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
</dependency>