Backend Development 11 min read

Introducing mybatis-plus-generator-ui: A Web UI Code Generator for MyBatis-Plus

This article presents mybatis-plus-generator-ui, a web‑based code generation framework that wraps MyBatis‑Plus, explains its features, shows how to integrate it via Maven and a Spring Boot entry point, demonstrates customization through templates and NameConverter, and provides guidance for building the UI frontend.

Selected Java Interview Questions
Selected Java Interview Questions
Selected Java Interview Questions
Introducing mybatis-plus-generator-ui: A Web UI Code Generator for MyBatis-Plus

In the MyBatis development ecosystem, many developers adopt MyBatis‑Plus to accelerate coding, but existing code generators often lack flexibility and multi‑database support; therefore a highly customizable, UI‑driven generator that works with most relational databases is needed.

mybatis-plus-generator-ui is a web UI wrapper around the MyBatis‑Plus generator, enabling rapid generation of Spring Boot‑compatible code such as Entity, Mapper, Mapper.xml, Service, and Controller, with configurable templates, output parameters, and direct SQL‑based generation.

Key features include:

Table query and browsing of database schemas.

Configurable output for various code types (Entity, Mapper, Service, Controller, etc.).

Project import and template download/upload.

Strategy configuration for file‑generation options (overwrite, file types, etc.).

SQL input to automatically generate Mapper methods, DTOs, and ResultMaps.

Usage – Maven dependency:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.yelang</groupId>
  <artifactId>mybatis-plus-generator-ui-case</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <dependencies>
    <dependency>
      <groupId>com.github.davidfantasy</groupId>
      <artifactId>mybatis-plus-generator-ui</artifactId>
      <version>1.4.5</version>
    </dependency>
    <dependency>
      <groupId>org.postgresql</groupId>
      <artifactId>postgresql</artifactId>
      <version>42.2.25</version>
    </dependency>
  </dependencies>
</project>

Running as a standalone Spring Boot application:

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")
            .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);
    }
}

After starting the application, the console shows the listening port and template directory; accessing http://localhost:8068/ opens the UI where users can configure generation parameters and produce code.

Customization: Users can modify BTL templates in the frontend directory, adjust naming rules via the NameConverter interface (e.g., custom entity, mapper, service, controller names), and add new output file types. After changes, compile the UI with:

yarn install
yarn run build

The article concludes by summarizing the capabilities of mybatis-plus-generator-ui and provides the GitHub repository link for further exploration.

backendJavacode generationSpring BootMyBatis-Plustool
Selected Java Interview Questions
Written by

Selected Java Interview Questions

A professional Java tech channel sharing common knowledge to help developers fill gaps. Follow us!

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.