Mybatis-Plus Generator UI: A Web UI Tool for Custom Code Generation in Spring Boot
This article introduces the Mybatis-Plus Generator UI, a highly customizable web‑based code generator that wraps Mybatis‑Plus, explains its features, shows how to integrate it via Maven, run a sample main class, configure generation strategies, customize templates and naming rules, and even extend the frontend with Yarn builds.
In Mybatis development, many developers use Mybatis‑Plus to improve efficiency, but existing code generators often lack flexibility and multi‑database support. This article presents mybatis-plus-generator-ui , a web UI based generator that wraps mybatis-plus-generator and can quickly produce business code compatible with Spring Boot and Mybatis‑Plus.
The tool provides an interactive UI to generate code for Entity, Mapper, Mapper.xml, Service, Controller and other components, allowing custom templates and output parameters, and supports common relational databases such as PostgreSQL, Oracle, DB2, MySQL and SQL Server.
Key features include table query, output configuration, project import, template download/upload, strategy configuration, SQL input upload, and SQL‑based code generation.
To use the generator, add the following Maven dependency to your project:
4.0.0
com.yelang
mybatis-plus-generator-ui-case
0.0.1‑SNAPSHOT
com.github.davidfantasy
mybatis-plus-generator-ui
1.4.5
org.postgresql
postgresql
42.2.25Then create a main class to start the generator server:
package com.yelang;
import com.github.davidfantasy.mybatisplus.generatorui.GeneratorConfig;
import com.github.davidfantasy.mybatisplus.generatorui.MybatisPlusToolsApplication;
import com.github.davidfantasy.mybatisplus.generatorui.mbp.NameConverter;
public class GeneratorMain {
public static void main(String[] args) {
GeneratorConfig config = GeneratorConfig.builder()
.jdbcUrl("jdbc:postgresql://127.0.0.1:5432/ghyapp")
.userName("ghy01").password("ghy01")
.driverClassName("org.postgresql.Driver")
// .schemaName("myBusiness") // for POSTGRE_SQL, ORACLE, DB2
.nameConverter(new NameConverter() {
/** custom Service name */
public String serviceNameConvert(String tableName) {
return this.entityNameConvert(tableName) + "Service";
}
/** custom Controller name */
public String controllerNameConvert(String tableName) {
return this.entityNameConvert(tableName) + "Action";
}
})
.basePackage("com.github.davidfantasy.mybatisplustools.example")
.port(8068)
.build();
MybatisPlusToolsApplication.run(config);
}
}Running the main method starts a server on port 8068; opening http://localhost:8068/ in a browser displays the UI where tables can be browsed, generation options configured, and code produced.
The UI supports table browsing, output configuration (Entity, Mapper, Service, Controller, etc.), strategy settings (overwrite, file types), and SQL‑based generation that creates Mapper methods, DTOs and ResultMaps from custom queries.
For deeper customization, developers can modify the BTL templates or implement a custom NameConverter to change naming rules for entities, fields, mappers, services, and controllers. Example interface snippets are provided to illustrate how to override default conversions.
If UI changes are needed, the frontend source under src/frontend can be edited and rebuilt with Yarn:
yarn install
yarn run buildIn summary, the article demonstrates how to integrate, use, and extend mybatis-plus-generator-ui for rapid backend code generation in Java projects, offering a practical solution for teams that require highly configurable scaffolding.
Selected Java Interview Questions
A professional Java tech channel sharing common knowledge to help developers fill gaps. Follow us!
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.