目录
官网xml
pom引入
在resources新建generatorConfig.xml
xml修改
生成
官网xml
MyBatis Generator Core – MyBatis Generator XML Configuration File Reference
pom引入
<!-- mybatis逆向生成器 -->
<dependency>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
<version>1.3.2</version>
</dependency>
<plugin>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
<version>1.3.2</version>
</plugin>
在resources新建generatorConfig.xml
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:\mysql-connector-java-5.1.24-bin.jar" />
<context id="DB2Tables" targetRuntime="MyBatis3">
<!--不生成注释-->
<commentGenerator>
<property name="suppressDate" value="true"/>
<property name="suppressAllComments" value="true"/>
</commentGenerator>
<jdbcConnection driverClass="com.mysql.jdbc.Driver"
connectionURL="jdbc:mysql://localhost:3306/im_bird"
userId="root"
password="root">
</jdbcConnection>
<javaTypeResolver >
<property name="forceBigDecimals" value="false" />
</javaTypeResolver>
<!--实体类-->
<javaModelGenerator targetPackage="org.wdzl.pojo" targetProject="src\main\java" />
<!-- xxxMapper.xml -->
<sqlMapGenerator targetPackage="org.wdzl.mapper" targetProject="src\main\resources" />
<!-- mapper接口位置 -->
<javaClientGenerator type="XMLMAPPER" targetPackage="org.wdzl.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>
生成
双击