CoderTools

MyBatis Generator

Generate MyBatis Mapper, Entity and Interface from table structure

Configuration

Table Structure

XML Mapper File

Documentation

What is MyBatis Generator?

MyBatis Generator is a tool that automatically generates MyBatis configuration files from database table structures. It can generate XML Mapper files, Java Entity classes, and Mapper interfaces, significantly reducing boilerplate code and improving development efficiency.

How to Use

  1. 1. Enter table DDL statement or JSON format table structure
  2. 2. Configure package name, author and other options
  3. 3. Select database type and whether to use Lombok
  4. 4. Click "Generate" button

Input Formats

DDL Format

CREATE TABLE users (
  id INT PRIMARY KEY AUTO_INCREMENT,
  username VARCHAR(50) NOT NULL,
  email VARCHAR(100),
  created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

JSON Format

{
  "tableName": "users",
  "columns": [
    {"name": "id", "type": "INT", "primaryKey": true},
    {"name": "username", "type": "VARCHAR", "length": 50},
    {"name": "email", "type": "VARCHAR", "length": 100},
    {"name": "created_at", "type": "TIMESTAMP"}
  ]
}

Key Features

  • Generate complete XML Mapper files with CRUD operations
  • Generate Java Entity classes with getters/setters or Lombok
  • Generate Mapper interface with method signatures
  • Support Lombok annotations (@Data)
  • Support MySQL, PostgreSQL, Oracle, SQL Server
  • Automatic naming conversion (underscore to camelCase)