mybatis generator自动生成dao,model,mapper文件

generator.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:\software\lib\mysql-connector-java-5.1.21.jar" /> -->
	<classPathEntry location="D:\tools\mysql-connector-java\mysql6.0.jar" />
	<context id="DB2Tables" targetRuntime="MyBatis3">
		 <!-- 抑制警告 -->
		 <property name="suppressTypeWarnings" value="true" />
		 <!-- generate entity时,生成hashcode和equals方法 -->  
        <plugin type="org.mybatis.generator.plugins.EqualsHashCodePlugin" />  
        <!-- generate entity时,生成serialVersionUID -->  
        <plugin type="org.mybatis.generator.plugins.SerializablePlugin" /> 
		<commentGenerator>
			<property name="suppressAllComments" value="true" />
		</commentGenerator>
		<!-- 数据库链接URL、用户名、密码 -->
		<!-- <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://localhost:3306/sy" userId="sypro" password="sypro"> -->
		<jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://localhost:3306/test" userId="root" password="root">
		</jdbcConnection>
		<javaTypeResolver>
			<property name="forceBigDecimals" value="false" />
		</javaTypeResolver>
		<!-- 生成模型的包名和位置 -->
		<javaModelGenerator targetPackage="myproject.model" targetProject="D:\workspace\generator\src">
			<property name="enableSubPackages" value="true" />
			<property name="trimStrings" value="true" />
		</javaModelGenerator>
		<!-- 生成的映射文件包名和位置 -->
		<sqlMapGenerator targetPackage="myproject.mapping" targetProject="D:\workspace\generator\src">
			<property name="enableSubPackages" value="true" />
		</sqlMapGenerator>
		<!-- 生成DAO的包名和位置 -->
		<javaClientGenerator type="XMLMAPPER" targetPackage="myproject.dao" targetProject="D:\workspace\generator\src">
			<property name="enableSubPackages" value="true" />
		</javaClientGenerator>
		<!-- 要生成那些表(更改tableName和domainObjectName就可以) ,由于表text类型的字段会造成单独生成一个XXXXWithBlobs类,加个columnOverride转换下
		-->
		<table tableName="trade" domainObjectName="Trade" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false">
		<columnOverride column="attribute" javaType="java.lang.String" jdbcType="VARCHAR" />  
		<columnOverride column="remark" javaType="java.lang.String" jdbcType="VARCHAR" />  </table>

		<table tableName="customer_bank" domainObjectName="CustomerBank" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" />

		<table tableName="trade_extend" domainObjectName="TradeExtend" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false">
		<columnOverride column="responsibility_info_json" javaType="java.lang.String" jdbcType="VARCHAR" />
		<columnOverride column="bank_payinfo" javaType="java.lang.String" jdbcType="VARCHAR" /></table>

		
	</context>
</generatorConfiguration>

生成语句:java -jar mybatis-generator-core-1.3.2.jar -configfile generator.xml -overwrite。

mybatis-generator-core-1.3.2.jar下载地址:http://download.csdn.net/download/varose/9790213


shift+ctrl+右击,复制粘贴生成语句。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值