1.安装插件(eclipse的marketplace中搜索mybatis就行了)

2.创建generatorConfig.xml文件(配置数据库等信息,读懂这个文件的内容就行了)

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="E:/jar/mysql-connector-java-5.1.25.jar" />
<context id="context1">
<plugin type="org.mybatis.generator.plugins.SerializablePlugin"></plugin>
<commentGenerator>
<property name="suppressAllComments" value="true" />
</commentGenerator>
<jdbcConnection driverClass="com.mysql.jdbc.Driver"
connectionURL="jdbc:mysql://127.0.0.1:3306/hongbaodb?characterEncoding=utf8"
userId="kevinLee" password="1234" />
<javaModelGenerator targetPackage="com.ithaha.pojo"
targetProject="redpacket" />
<sqlMapGenerator targetPackage="com.ithaha.mapper"
targetProject="redpacket" />
<javaClientGenerator targetPackage="com.ithaha.mapper"
targetProject="redpacket" type="XMLMAPPER" />
<table schema="RedPacket" tableName="t_red_packet"
enableCountByExample="false" enableUpdateByExample="false"
enableDeleteByExample="false" enableSelectByExample="false"
selectByExampleQueryId="false" domainObjectName="RedPacket"></table>
<table schema="UserRedPacket" tableName="t_user_red_packet"
enableCountByExample="false" enableUpdateByExample="false"
enableDeleteByExample="false" enableSelectByExample="false"
selectByExampleQueryId="false" domainObjectName="UserRedPacket"></table>
</context>
</generatorConfiguration>
3.生成对应实体类和mapper文件
