MyBatis Generator
Generate MyBatis XML Mapper, Entity and Mapper Interface from table structure
Configuration
Table Structure (DDL or JSON)
UserMapper.xml
MyBatis Generator Documentation
What is MyBatis?
MyBatis is a first-class persistence framework with support for custom SQL, stored procedures and advanced mappings. MyBatis eliminates almost all of the JDBC code and manual setting of parameters and retrieval of results.
How to Use This Tool
- Configure package name and table name
- Paste your CREATE TABLE DDL or table structure JSON
- Click "Generate MyBatis Files" button
- Copy generated XML Mapper, Entity class and Mapper interface
Supported Input Formats
DDL Format (CREATE TABLE)
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
- Generate Java Entity classes with getters/setters
- Generate Mapper interface with CRUD methods
- Support Lombok annotations
- Support multiple database types
- Automatic naming conversion (underscore to camelCase)