Java MyBatis自动生成映射文件

参考:http://blog.csdn.net/tolcf/article/details/50835165 文章中提供了jar包下载地址

generatorConfig.xml 如下,mybatis自动化工具会根据该文件来查找数据源,生成对应的VO对象,mapper文件,example对象

<?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:\generator\mysql-connector-java-5.1.34.jar" /> 
    <!-- <classPathEntry location="C:\oracle\product\10.2.0\db_1\jdbc\lib\ojdbc14.jar" />-->
    <context id="DB2Tables" targetRuntime="MyBatis3">
        <commentGenerator>
            <property name="suppressAllComments" value="true" /> <!--生成注释-->
            <property name="suppressDate" value="true" /> <!--生成注释包含时间戳-->
        </commentGenerator>
        <!-- 数据库链接URL、用户名、密码 -->
         <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://127.0.0.1:3306/vpush_dev?characterEncoding=utf8" userId="yq" password="123456"> 
        <!--<jdbcConnection driverClass="oracle.jdbc.driver.OracleDriver" connectionURL="jdbc:oracle:thin:@localhost:1521:orcl" userId="msa" password="msa">-->
        </jdbcConnection>
        <javaTypeResolver>
            <property name="forceBigDecimals" value="false" />
        </javaTypeResolver>
        <!-- 生成模型的包名和位置 -->
        <javaModelGenerator targetPackage="yq.model" targetProject="D:\generator\src">
            <property name="enableSubPackages" value="true" />
            <property name="trimStrings" value="true" />
        </javaModelGenerator>
        <!-- 生成的映射文件包名和位置 -->
        <sqlMapGenerator targetPackage="yq.mapping" targetProject="D:\generator\src">
            <property name="enableSubPackages" value="true" />
        </sqlMapGenerator>
        <!-- 生成DAO的包名和位置 -->
        <javaClientGenerator type="XMLMAPPER" targetPackage="yq.dao" targetProject="D:\generator\src">
            <property name="enableSubPackages" value="true" />
        </javaClientGenerator>
        <!-- 要生成那些表(更改tableName和domainObjectName就可以) -->
                <table schema="test" tableName="device">
            <generatedKey column="ID" sqlStatement="Mysql" identity="true"/>
        </table>
        <table schema="test" tableName="device_push">
            <generatedKey column="ID" sqlStatement="Mysql" identity="true"/>
        </table>
        <table schema="test" tableName="model_info">
            <generatedKey column="ID" sqlStatement="Mysql" identity="true"/>
        </table>
        <table schema="test" tableName="os_version">
            <generatedKey column="ID" sqlStatement="Mysql" identity="true"/>
        </table>
        <table schema="test" tableName="push_task">
            <generatedKey column="ID" sqlStatement="Mysql" identity="true"/>
        </table>
        <table schema="test" tableName="test_process">
            <generatedKey column="ID" sqlStatement="Mysql" identity="true"/>
        </table>
        <table schema="test" tableName="test_tool">
            <generatedKey column="ID" sqlStatement="Mysql" identity="true"/>
        </table>
        <table schema="test" tableName="tool_version">
            <generatedKey column="ID" sqlStatement="Mysql" identity="true"/>
        </table>
        <table schema="test" tableName="dic_config">
            <generatedKey column="ID" sqlStatement="Mysql" identity="true"/>
        </table>
        <table schema="test" tableName="server_node">
            <generatedKey column="ID" sqlStatement="Mysql" identity="true"/>
        </table>
        <table schema="test" tableName="test_item">
            <generatedKey column="ID" sqlStatement="Mysql" identity="true"/>
        </table>
        <table schema="test" tableName="test_report">
            <generatedKey column="ID" sqlStatement="Mysql" identity="true"/>
        </table>
        <table schema="test" tableName="user_info">
            <generatedKey column="ID" sqlStatement="Mysql" identity="true"/>
        </table>
    </context>
</generatorConfiguration>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值