MyEclipse使用MyBatis Generator 工具逆向生成映射文件

下载mybatis generator插件

 

将features、plugins拷贝到myeclipse10下的dropins文件夹中,如下图所示,重启myeclipse。

 

 

以下以MySQL为例逆向生成映射文件,其中数据库为test表为userinfo,id字段自增。

创建一新的web project  mybatis_generator,并添加sql驱动jar包。

在src中创建一个MyBatis生成orm文件的配置文件,单击next,保持默认设置finish即可。

 

 

对生成的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>
    <context id="context1" targetRuntime="MyBatis3Simple">

        <!-- 配置注释 -->
        <commentGenerator>
            <property name="suppressAllComments" value="false"/><!-- 配置是否取消注释 -->  
            <property name="suppressDate" value="true" /><!-- 配置 注释是否显示日期 -->
        </commentGenerator>

        <!-- 配置jdbc连接数据库-->
        <jdbcConnection driverClass="com.mysql.jdbc.Driver"
            connectionURL="jdbc:mysql://192.168.4.249:3306/cloud_canteen_group" userId="root"
            password="1" />
        <!-- 配置生成的实体类放置 -->
        <javaModelGenerator targetPackage="vo" targetProject="cloud_canteen_api_db/src/main/java" />

        <!-- 配置生成的实现文件XML放置 -->
        <sqlMapGenerator targetPackage="mapper" targetProject="cloud_canteen_api_db/src/main/java" />

        <!-- 配置生成的dao接口放置 -->
        <javaClientGenerator targetPackage="dao" targetProject="cloud_canteen_api_db/src/main/java" type="XMLMAPPER" />

        <!-- 配置要生成的实体对应的表 % 代表所有表 -->
        <table schema="scott" tableName="order_payrec" enableCountByExample="false" enableUpdateByExample="false"
        enableDeleteByExample="false" enableSelectByExample="false"
        selectByExampleQueryId="false"
        >
        </table>

        <!-- 配置要生成的实体对应的类名 
            <table schema="scott" tableName="t_10_01_student" domainObjectName="Stduent"> </table>
         -->
    </context>
</generatorConfiguration>

右键配置文件,选择Generator MyBatis/iBATIS Artifacts即可生成orm映射文件

转载于:https://my.oschina.net/liting/blog/913795

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值