mybatis-plus-generator-ui可视化生成mybatis plus+MVC代码
mybatis-plus-generator-ui可视化生成mybatis plus+MVC代码
https://github.com/davidfantasy/mybatis-plus-generator-ui
引入依赖
<dependency>
<groupId>com.github.davidfantasy</groupId>
<artifactId>mybatis-plus-generator-ui</artifactId>
<version>2.0.1</version>
<scope>compile</scope>
</dependency>
启动main方法
package com.alibaba.web.alibabafeign;
import cn.hutool.core.util.StrUtil;
import com.github.davidfantasy.mybatisplus.generatorui.GeneratorConfig;
import com.github.davidfantasy.mybatisplus.generatorui.MybatisPlusToolsApplication;
import com.github.davidfantasy.mybatisplus.generatorui.mbp.NameConverter;
import com.google.common.base.Strings;
/**
* @date :Created 2023/5/23 17:41
* @description :
*/
public class GeneratorMain {
public static void main(String[] args) {
GeneratorConfig config = GeneratorConfig.builder().jdbcUrl("jdbc:mysql://172.16.100.184:33061/unimis_test?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true")
.userName("root").password("5aAdmin@zhida.com").driverClassName("com.mysql.cj.jdbc.Driver")
// 数据库schema,POSTGRE_SQL,ORACLE,DB2类型的数据库需要指定
// .schemaName("myBusiness")
// 如果需要修改各类生成文件的默认命名规则,可自定义一个NameConverter实例,覆盖相应的名称转换方法:
.nameConverter(new NameConverter() {
@Override
public String entityNameConvert(String tableName) {
if (Strings.isNullOrEmpty(tableName)) {
return "";
} else {
// tableName = tableName.substring(tableName.indexOf("_") + 1);
String[] s = tableName.split("_");
tableName = "";
for (String s1 : s) {
tableName += StrUtil.upperFirst(s1);
}
return tableName;
}
}
/**
* 自定义Service类文件的名称规则
*/
@Override
public String serviceNameConvert(String tableName) {
return this.entityNameConvert(tableName) + "Service";
}
/**
* 自定义Controller类文件的名称规则
*/
@Override
public String controllerNameConvert(String tableName) {
return this.entityNameConvert(tableName) + "Controller";
}
}).basePackage("com.alibaba.web.alibabafeign").port(8068).build();
MybatisPlusToolsApplication.run(config);
}
}
访问页面如图:
点击【代码生成】
生成代码如下: