zoukankan      html  css  js  c++  java
  • Mybatis逆向生成

    在已经有了数据库的表的时候,为了方便起见,我们可以逆向生成javabean,xml,dao接口等,当然,下载mybaits-generation的工具,我这里用的是eclipse插件,然后准备一 个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.22-bin.jar"/>
      <context id="context1" >
              <commentGenerator>  
                <property name="suppressDate" value="true"/>  
                <!-- 是否去除自动生成的注释,这些注释没有什么用,就是一些时间信息什么的,强烈建议去掉, true:是 : false:否 -->  
                <property name="suppressAllComments" value="true"/>  
            </commentGenerator> 
      
      
        <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://120.25.221.96:43305/test_coupens?useUnicode=true&amp;characterEncoding=utf8" userId="testujia007.com" password="testujia007.com" />
        <javaModelGenerator targetPackage="com.tbs.entity" targetProject="system_admin" >
                <property name="enableSubPackages" value="true"/>  
                <property name="trimStrings" value="true"/>  
        </javaModelGenerator>
        <!-- 生成sql映射文件的包名,项目名 -->
        <sqlMapGenerator targetPackage="com.tbs.mapper" targetProject="system_admin" />
        <!-- 生成dao接口的包名,项目名 -->
        <javaClientGenerator targetPackage="com.tbs.dao" targetProject="system_admin" type="XMLMAPPER" /> 
        <!-- 要生成哪些表-->  
        <table tableName="" domainObjectName="CouponUseCustomer"  enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false">
            <!-- 使用这个,很重要,它会把数据库中的字段,原封不动的写成javabean,如果不写,或者写为false,就会把一些特殊字符,给去掉,如“_” -->
            <property name="useActualColumnNames" value="true"/>
        </table>
      </context>
    </generatorConfiguration>
  • 相关阅读:
    php ajax 表格排序,调整列宽,修改内容
    Jquery隐藏式评论
    还是一个鼠标点击td变成input,失去焦点更新数据库
    Jquery php 点击td变成input,修改后失去焦点发送数据
    hdu 1713 相遇周期 比较绕的最大公约,最小公倍问题
    hdu 1722 Cake (抽象出欧几里得)
    提供Webservice的地方
    实现汉字转拼音
    java 注解
    c#获取汉字的拼音首字母
  • 原文地址:https://www.cnblogs.com/zhuxiaojie/p/5022185.html
Copyright © 2011-2022 走看看