您的位置:首页 > 其它

Mybatis逆向生成

2015-12-05 20:12 309 查看
在已经有了数据库的表的时候,为了方便起见,我们可以逆向生成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&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>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: