MyBatis Code Generator
Generate MyBatis Mapper, Entity and interfaces from table structure
Configuration
Table Structure
About MyBatis Code Generator
MyBatis Generator is a tool that can automatically generate 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
- 1Enter table DDL statement or JSON format table structure
- 2Configure package name, database type, and other options
- 3Choose whether to use Lombok and generate comments
- 4Click the '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 getter and setter or Lombok support
- Generate Mapper interfaces and method signatures
- Support Lombok annotations '(' @Data ')'
- Support MySQL, PostgreSQL, Oracle, SQL Server
- Automatic naming conversion '(' underscore to camelCase ')'
FAQ
What is MyBatis Code Generator?
MyBatis Code Generator is a tool that can automatically generate MyBatis persistence layer code (XML Mapper, Java Entity classes, DAO interfaces) based on database table structures (DDL), helping developers save time writing repetitive code.
Does it support Lombok?
Yes, after checking the 'Use Lombok Annotations' option, the generated entity classes will use the @Data annotation, eliminating the need to manually write getter and setter methods.
Which databases are supported?
Currently supports four mainstream databases: MySQL, PostgreSQL, Oracle, and SQL Server.
Can the generated code be used directly?
The generated code can be used directly, but it is recommended to make appropriate adjustments and optimizations based on actual business requirements.