1、插件市场下载better-mybatis-generator

【MyBatis】better-mybatis-generator 插件快速生成dao、pojo、xml教程_xml

2、IDEA连接数据库

【MyBatis】better-mybatis-generator 插件快速生成dao、pojo、xml教程_mysql_02

配置你的MySQL驱动 如果是5.0多的驱动Class配置com.mysql.jdbc.Driver

如果是8.0多驱动 配置是 com.mysql.cj.jdbc.Driver

【MyBatis】better-mybatis-generator 插件快速生成dao、pojo、xml教程_mybatis_03

1、用户名

2、密码

3、数据库名

4、URL(mysql 8.0后面必须添加 ?serverTimezone=GMT&useSSL=false ) 

【MyBatis】better-mybatis-generator 插件快速生成dao、pojo、xml教程_mybatis_04

测试连接Succeeded就是没有问题

【MyBatis】better-mybatis-generator 插件快速生成dao、pojo、xml教程_mybatis_05

 右击选择你要自动生成代码的数据库 选择mybatis-generate

【MyBatis】better-mybatis-generator 插件快速生成dao、pojo、xml教程_java_06

修改实体类名、mapper名、配置实体类路径、mapper路面、xml包名 mysql8.0勾上 

【MyBatis】better-mybatis-generator 插件快速生成dao、pojo、xml教程_bc_07

 dao、pojo、xml就生成好了

【MyBatis】better-mybatis-generator 插件快速生成dao、pojo、xml教程_xml_08