Backend Development 5 min read

Using MybatisX Plugin with Spring Boot for Rapid MyBatis Development

This guide demonstrates how to integrate the MybatisX IDEA plugin with a Spring Boot project, covering database setup, Maven dependency configuration, plugin installation, connection testing, code generation, and sample controller implementation to accelerate MyBatis and MyBatis-Plus development.

Code Ape Tech Column
Code Ape Tech Column
Code Ape Tech Column
Using MybatisX Plugin with Spring Boot for Rapid MyBatis Development

MybatisX is an IntelliJ IDEA plugin designed to streamline MyBatis and MyBatis-Plus development by automating repetitive persistence‑layer tasks and boosting coding speed.

Benefits of using MybatisX: it saves a large amount of time writing persistence code, offers powerful features that support business development, and provides simple configuration without complex XML files.

Step‑by‑step usage:

1. Create a simple database.

2. Create a basic Spring Boot project.

3. Add the MyBatis‑Plus starter dependency to pom.xml :

<!--mybatisPlus-->
<dependency>
    <groupId>com.baomidou</groupId>
    <artifactId>mybatis-plus-boot-starter</artifactId>
    <version>3.5.1</version>
</dependency>

4. Install the MybatisX plugin via File → Settings → Plugins → Marketplace and search for "MybatisX".

5. Use the shortcut SHIFT+SHIFT to open the database tool window, then create a new MySQL connection, entering the username, password, and database name.

If the test connection fails due to a timezone issue, set serverTimezone=GMT in the connection's advanced settings.

After a successful connection, the database schema and tables become visible. Right‑click a table and select MybatisX‑Generator to open the generation wizard.

In the wizard, configure prefix/suffix removal, output directories, and select the latest MyBatis‑Plus version along with Lombok for simplified development.

Finish the wizard and MybatisX will generate the entity class, Mapper XML, Service, and corresponding interface for the selected table.

Configure the datasource in application.yaml :

spring:
  datasource:
    driver-class-name: com.mysql.cj.jdbc.Driver
    url: jdbc:mysql://localhost:3306/user?characterEncoding=utf-8&useSSL=false&serverTimezone=GMT
    username: root
    password: password

Example controller using MyBatis‑Plus's query wrapper:

package com.example.mybatixtest.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.mybatixtest.pojo.User;
import com.example.mybatixtest.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class TestController {
    @Autowired
    UserService userService;

    @GetMapping("/test")
    public User test() {
        QueryWrapper
userQueryWrapper = new QueryWrapper<>();
        userQueryWrapper.eq("user_id", 1);
        User user = userService.getOne(userQueryWrapper);
        return user;
    }
}

Running the application and accessing /test returns the expected user data, confirming that MybatisX integration with Spring Boot is complete.

Javabackend developmentSpring BootMyBatisMyBatis-PlusIDEA plugin
Code Ape Tech Column
Written by

Code Ape Tech Column

Former Ant Group P8 engineer, pure technologist, sharing full‑stack Java, job interview and career advice through a column. Site: java-family.cn

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.