MyBatis Generator生成sqlMap、DAO、mo

附件下载地址:http://pan.baidu.com/s/1bpgEZwz
附件中mybatis-generator-core-1.3.2.jar  、 mysql-connector-5.1.25-bin.jar  、 a.bat  、 generatorConfig.xml。
其中mybatis-generator-core-1.3.2.jar是生成sqlMap等需要用到的jar, mysql-connector-5.1.25-bin.jar为连接sql用到的sqlMap . ;a.bat是处理命令 。 
generatorConfig.xml为生成sqlmap的配置文件。


a.bat 、generatorConfig.xml 需要根据修改。
1、右键a.bat,编辑,根据自己的实际路径修改a.bat中jar包路径和配置文件路径。
2、generatorConfig.xml 修改:
<pre name="code" class="html"><?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="C:/Users/Administrator/Downloads/myibatis_10586/mysql-connector-5.1.25-bin.jar" />
	<context id="context1">
		<commentGenerator>
			<property name="suppressDate" value="true" />
		</commentGenerator>
		<jdbcConnection driverClass="com.mysql.jdbc.Driver"
			connectionURL="jdbc:mysql://localhost:3306/test_web"
			userId="root" password="root">
		</jdbcConnection>
		<javaTypeResolver>
			<property name="forceBigDecimals" value="false" />
		</javaTypeResolver>
		 <!--生成Model类存放位置-->
		<javaModelGenerator targetPackage="com.sql.sqlmap.model"
			targetProject="D:\Workspaces_yy_v_1_4_1\TestDB2sqlmap\src" />
		<!--生成映射文件存放位置-->
		<sqlMapGenerator targetPackage="com.sql.sqlmap.mapper"
			targetProject="D:\Workspaces_yy_v_1_4_1\TestDB2sqlmap\src" />
		<!--生成Dao类存放位置-->
		<javaClientGenerator targetPackage="com.sql.sqlmap.mapper"
			targetProject="D:\Workspaces_yy_v_1_4_1\TestDB2sqlmap\src" type="XMLMAPPER">
			<property name="enableSubPackages" value="true" />
		</javaClientGenerator>
	
		 <!--生成对应表及类名-->
		<!-- 其中tableName是必填的,domainObjectName默认是tableName首字母大写。
		 enableCountByExample、enableUpdateByExample、enableDeleteByExample 、enableSelectByExample、selectByExampleQueryId
		 默认为true,生成对应sqlMap中的方法-->
		 <table tableName="user" domainObjectName="User" enableCountByExample="true" enableUpdateByExample="true" enableDeleteByExample="true" enableSelectByExample="true" selectByExampleQueryId="true"></table>
		<table tableName="message" domainObjectName="Messgae" enableCountByExample="true" enableUpdateByExample="true" enableDeleteByExample="true" enableSelectByExample="true" selectByExampleQueryId="true"></table>
		<table tableName="info" domainObjectName="Info" enableCountByExample="true" enableUpdateByExample="true" enableDeleteByExample="true" enableSelectByExample="true" selectByExampleQueryId="true"></table>
</context>
</generatorConfiguration>


 
connectionURL:改为相应的数据库连接地址。
userId :数据库用户名
password :数据库连接密码
javaModelGenerator 、sqlMapGenerator  、 javaClientGenerator 标签 需要根据实际的包名以及路径来修改。
table 标签 填写的是需要生成DAO、model、sqlMap的表。tableName必填,其他可选。domainObjectName默认是表名首字母大写。
enableCountByExample、enableUpdateByExample 、enableDeleteByExample、enableSelectByExample、selectByExampleQueryId默认
为true。


3、配置好a.bat以及eneratorConfig.xml 后,双击a.bat运行。
4、运行成功后可以在targetPackage(此处为com.sql.sqlmap.model和com.sql.sqlmap.mapper)处看到model、dao、sqlMap。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值