Boost Your Java Backend: Master MyBatisCodeHelper Pro for Rapid Code Generation

This guide walks you through installing the MyBatisCodeHelper‑Pro IntelliJ plugin, configuring it to generate Java entity, DAO, mapper and service code, customizing type mappings, creating SQL scripts, and using shortcuts to produce find, update, delete, and pagination methods efficiently for backend development.

Java High-Performance Architecture
Java High-Performance Architecture
Java High-Performance Architecture
Boost Your Java Backend: Master MyBatisCodeHelper Pro for Rapid Code Generation

Installation

Address: https://github.com/gejun123456/MyBatisCodeHelper-Pro

Installation

In IntelliJ install the latest plugin MybatisCodeHelper-2.8.1-191-201 and activate it via

Tools → MybatisCodeHelper → Activation → OfflineActivation

, entering any string as the offline key.

Configuration

By default tinyInt/smallInt map to byte and short; you can configure the plugin to use Integer instead and to use Java 8 date‑time types.

Usage

Maven Dependencies

Add the following dependencies to ensure generated code compiles without errors:

<dependency>
  <groupId>org.mybatis</groupId>
  <artifactId>mybatis</artifactId>
  <version>3.5.4</version>
</dependency>

<dependency>
  <groupId>org.projectlombok</groupId>
  <artifactId>lombok</artifactId>
  <version>1.18.10</version>
</dependency>

<dependency>
  <groupId>com.github.pagehelper</groupId>
  <artifactId>pagehelper</artifactId>
  <version>5.1.11</version>
</dependency>

<!-- Guarantee proper Service annotations -->
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-webmvc</artifactId>
    <version>5.2.1.RELEASE</version>
</dependency>

Generate Table SQL from Entity

Press Alt+Insert on an entity class to generate the CREATE TABLE statement, then execute it in the database.

After the table exists, generate CRUD code from the database.

Steps: connect to MySQL in IntelliJ, right‑click the table, configure generation options (disable example files, avoid mapper inheritance, enable generated comments, etc.), then view the generated directories.

Generate Mapper Methods

Place the cursor on a mapper interface method name and press Alt+Enter → Generate mybatis mapper for current class to create the corresponding XML mapping. find (or select query get) supports orderBy, distinct, findFirst. update can be replaced by modify. delete can be replaced by remove. count supports distinct.

Generate Unit Tests (Non‑Spring)

Position the cursor on a mapper method declaration and press Alt+Enter to generate a test method.

public class DaShangMapperTest {
    private static DaShangMapper mapper;

    @BeforeEach
    public static void setUpMybatisDatabase() {
        SqlSessionFactory builder = new SqlSessionFactoryBuilder()
            .build(DaShangMapperTest.class.getClassLoader()
            .getResourceAsStream("mybatisTestConfiguration/DaShangMapperTestConfiguration.xml"));
        mapper = builder.getConfiguration()
            .getMapper(DaShangMapper.class, builder.openSession(true));
    }

    @Test
    public void testInsertDaShang() throws FileNotFoundException {
        mapper.insertDaShang();
    }
}

Tips

Ctrl‑click a field in mapper.xml to jump to the corresponding database column.

Right‑click an entity class and choose “generate mybatis files” to create the entity, mapper, mapper.xml, service and service implementation.

Unique: unique index, non‑repeatable.

Index: ordinary index, repeatable.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

BackendJavaCode GenerationMyBatisdaomapperIntelliJ
Java High-Performance Architecture
Written by

Java High-Performance Architecture

Sharing Java development articles and resources, including SSM architecture and the Spring ecosystem (Spring Boot, Spring Cloud, MyBatis, Dubbo, Docker), Zookeeper, Redis, architecture design, microservices, message queues, Git, etc.

0 followers
Reader feedback

How this landed with the community

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.