MyBatis Generator

MyBatis Generator

一.

    下载 mybatis-generator-core-1.3.2.jar    以及   mysql-connector-java-5.1.26

     下载地址:  http://pan.baidu.com/s/1tlrx8 

二.

    配置文件 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="mysql-connector-java-5.1.26.jar" />
	<context id="MySQL" defaultModelType="flat" targetRuntime="MyBatis3">
		<commentGenerator>
			<!-- 是否去除自动生成的注释 true:是 : false:否 -->
			<property name="suppressAllComments" value="true" />
		</commentGenerator>
		<!-- 数据库连接信息:驱动类、URL、用户名、密码 -->
		<jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://localhost:3306/mms" userId="root" password="root"></jdbcConnection>
		<javaTypeResolver>
			<property name="forceBigDecimals" value="false" />
		</javaTypeResolver>
		<!-- 生成模型的包名和位置 -->
		<javaModelGenerator targetPackage="com.letv.mms.po" targetProject="E:\mms-common\src\main\java">
			<property name="enableSubPackages" value="true" />
			<property name="trimStrings" value="true" />
		</javaModelGenerator>
		<!-- 生成的映射文件包名和位置 -->
		<sqlMapGenerator targetPackage="	MyBatis" targetProject="E:\mms-common\src\main\resources">
			<property name="enalbeSubPackages" value="true" />
		</sqlMapGenerator>
		<!-- 生成DAO的包名和位置 -->
		<javaClientGenerator type="XMLMAPPER" targetPackage="com.letv.mms.dao" targetProject="E:\mms-common\src\main\java">
			<property name="enableSubPackages" value="true" />
		</javaClientGenerator>
		<!-- 要生成哪此表(更改tableName和domainObjectName就可以) -->
		<table tableName="t_video_info" domainObjectName="VideoPO" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
		<table tableName="t_album_info" domainObjectName="AlbumPO" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
		<table tableName="t_category_info" domainObjectName="CategoryPO" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
		<table tableName="t_property_info" domainObjectName="PropertyPO" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
		<table tableName="t_mms_info" domainObjectName="MmsPO" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
	</context>
</generatorConfiguration>

 

几个注意事项:

    1.生成路径请勿用中文,可能会有warning   xxx does not exist

    2.targetPackage不可为空    异常:SQLMapGenerator Target Package is Required for context

    3.如遇其他问题可查看Mybatis官方文档 <generatorConfiguration>标签

 

三.运行脚本

    java -jar mybatis-generator-core-1.3.2.jar -configfile generator.xml -overwrite

注意路径问题  建议将Mybatis与MySQL的jar包放在同一文件夹下。

转载于:https://my.oschina.net/liyixiangBlog/blog/371753

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值