MyBatisCodeHelperPro is introduced:
- In the development process can help us through the database table generation write generation bean, mapper, mapper.xml and other files.
- Table building sentences can be generated from entity classes and then executed in the database after being adjusted as needed.
- Mapper and XML files can jump to and from each other.
- MyBatisCodeHelperPro is a plug-in of IDEA, similar to Mybatis plugin, but it needs to be charged, and can be activated by buying activation code if conditions exist.
2. Install
Because it is too slow to download MyBatisCodeHelperPro in IDEA, so I provide the link here for everyone to download, download the link extraction code: 0707 (personal web Disk sharing), click to select install Plugin from Disk, select a good path to install.
Use 3.
3.1 Entity class automatically generates table building sentences
1. Create an entity class
import lombok.Data; import java.util.Date; @data public class User {/** * primary key ID */ private Integer ID; /** * userName */ private String userName; /** * age */ private Integer age; /** * private String adress; /** * phone number */ private String phone; /** * private Date regTime; }Copy the code
2. In the entity class object, click on Generate and select Generate, then click on Generate MyBatis Files
3. You can make a few adjustments here, such as adding an index, and then generate the table builder
4. Adjust the table construction clauses as required and run them in the database.
-- auto Generated on 2020-08-25 -- DROP TABLE IF EXISTS `user`; CREATE TABLE 'user' (id INT (11) NOT NULL AUTO_INCREMENT COMMENT '主 库 iD ', User_name VARCHAR (50) NOT NULL DEFAULT 'COMMENT ', age INT (11) NOT NULL default-1 COMMENT' age ', Adress VARCHAR (50) NOT NULL DEFAULT COMMENT '', phone VARCHAR (50) NOT NULL DEFAULT COMMENT '', Reg_time DATETIME NOT NULL DEFAULT '1000-01-01 00:00:00' COMMENT 'register time ', PRIMARY KEY (id))ENGINE=InnoDB DEFAULT CHARSET= utf8MB4 COMMENT '表';Copy the code
3.2 Generate beans, mapper and mapper.xml according to the database table
1. In Database, right-click the Database table and select Mybatis Generator
2. Select the class you want to generate
Check myBatisPlus
3. Generate code