一、下载idea-mybatis-generator插件
部分pom.xml代码
<!--mybatis 逆向生成器-->
<dependency>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
<version>1.3.2</version>
</dependency>
<build>
<plugins>
<plugin>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
<version>1.3.2</version>
</plugin>
</plugins>
</build>
二、springboot项目resource下新建generatorConfig.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE generatorConfiguration
PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
"http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
<generatorConfiguration>
<classPathEntry location="D:\maven\maven_repository\mysql\mysql-connector-java\8.0.12\mysql-connector-java-8.0.12.jar" />
<context id="DB2Tables" targetRuntime="MyBatis3">
<!--不生成注释-->
<commentGenerator>
<property name="suppressDate" value="true"/>
<property name="suppressAllComments" value="true"/>
</commentGenerator>
<!--数据库信息-->
<jdbcConnection driverClass="com.mysql.cj.jdbc.Driver"
connectionURL="jdbc:mysql:///im_bird?useSSL=false&serverTimezone=UTC"
userId="root"
password="123456">
</jdbcConnection>
<javaTypeResolver >
<property name="forceBigDecimals" value="false" />
</javaTypeResolver>
<!--实体类-->
<javaModelGenerator targetPackage="com.keller.pojo" targetProject="src\main\java" />
<!--xxxMapper.xml-->
<sqlMapGenerator targetPackage="com.keller.mapper" targetProject="src\main\resources" />
<!--mapper接口位置-->
<javaClientGenerator type="XMLMAPPER" targetPackage="com.keller.mapper" targetProject="src\main\java" />
<!--数据库表对应的实体类-->
<table tableName="chat_msg" domainObjectName="ChatMsg" enableCountByExample="false" enableSelectByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" ></table>
<table tableName="friends_request" domainObjectName="FriendsRequest" enableCountByExample="false" enableSelectByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" ></table
<table tableName="my_friends" domainObjectName="MyFriends" enableCountByExample="false" enableSelectByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" ></table>
<table tableName="t_users" domainObjectName="User" enableCountByExample="false" enableSelectByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" ></table>
</context>
</generatorConfiguration>
三、双击mybatis-generator生成代码