Mybatis逆向工程是使用mybaits提供的插件,根据数据表结构生成对应的Xx.java(pojo)、XxMapper.xml、XxMapper.java、XxService.java、XxServiceImpl.java、XxController.java等。减少重复的板砖工作。
1.添加依赖包
<!-- mysql db -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<!--代码生成器-->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-generator</artifactId>
<version>3.5.1</version>
</dependency>
2.生成代码工具类
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.config.OutputFile;
import java.util.ArrayList;