码迷,mamicode.com
首页 > 其他好文 > 详细

Mybatis逆向生成

时间:2015-12-05 20:51:52      阅读:189      评论:0      收藏:0      [点我收藏+]

标签:

在已经有了数据库的表的时候,为了方便起见,我们可以逆向生成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>

 

Mybatis逆向生成

标签:

原文地址:http://www.cnblogs.com/zhuxiaojie/p/5022185.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!