Myeclispe下mybatis generator的使用

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/iteye_11587/article/details/82654183
准备:下载附件包解压到myeclispe的dropins文件夹下
选择项目
1.新建config文件

[img]http://dl2.iteye.com/upload/attachment/0118/4413/ab7f9d0e-6f58-3824-a10e-49dfcb908841.png[/img]
配置路径

[img]http://dl2.iteye.com/upload/attachment/0118/4421/bde3c189-f3df-35ff-a77a-d9b1d13b00e9.png[/img]


2.配置config
<?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:\lib\mysql-connector-5.1.8.jar" />
<context id="contextMybatis" >
<!--数据库链接地址账号密码-->
<jdbcConnection driverClass="com.mysql.jdbc.Driver"
connectionURL="jdbc:mysql://192.168.126.128:3306/test?useUnicode=true&characterEncoding=UTF-8"
userId="test"
password="test" />
<!--生成Model类存放位置-->
<javaModelGenerator targetPackage="Model" targetProject="Mybatis" />
<!--生成映射文件存放位置-->
<sqlMapGenerator targetPackage="Mapper" targetProject="Mybatis" />
<!--生成Dao类存放位置-->
<javaClientGenerator targetPackage="Dao" targetProject="Mybatis" type="XMLMAPPER" />
<!--生成对应表及类名-->
<table tableName="user"
domainObjectName="user" enableInsert="true"
enableSelectByPrimaryKey="true" enableUpdateByPrimaryKey="true"
enableDeleteByPrimaryKey="true" enableSelectByExample="false"
enableDeleteByExample="false" enableCountByExample="false"
enableUpdateByExample="false">
</table>
<table tableName="role"
domainObjectName="role" enableInsert="true"
enableSelectByPrimaryKey="true" enableUpdateByPrimaryKey="true"
enableDeleteByPrimaryKey="true" enableSelectByExample="false"
enableDeleteByExample="false" enableCountByExample="false"
enableUpdateByExample="false">
</table>
</context>
</generatorConfiguration>

3.右击配置文件,点击下图矩形框选项即可

[img]http://dl2.iteye.com/upload/attachment/0118/4423/2bded122-a013-377a-977a-27247b4300b0.png[/img]
展开阅读全文

没有更多推荐了,返回首页