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>
  • 相关阅读:
    POJ 2891 Strange Way to Express Integers 中国剩余定理解法
    @Repository @Service 和@Autowired 的使用
    POJ 3070 Fibonacci
    无线局域网技术
    第一次ACM赛后总结及感悟
    Subsets II -- LeetCode
    [WebView学习之二]:使用Web Apps 支持不同分辨率屏
    微信公众平台开发新手教程(图文具体解释)
    翻译-In-Stream Big Data Processing 流式大数据处理
    Nginx + FastCgi + Spawn-fcgi + C 架构的server环境搭建
  • 原文地址:https://www.cnblogs.com/zhuxiaojie/p/5022185.html
Copyright © 2011-2022 走看看