您的位置:首页 > 编程语言 > Java开发

mybatis generator eclipse插件的安装

2015-07-21 11:14 507 查看
目的:使用Spring+mybatis自动生成实体类,mapper.xml,mapper.java

方法:引入mybatisGenerator

操作:

1、下载mybatis generator eclipse插件离线包http://download.csdn.net/detail/gxl442172663/7624747#comment

2、将解压的features和plugins两个文件夹内文件复制到Eclipse安装目录对应的文件夹内。

3、重新启动Eclipse。

4、Eclipse中New–>Other–>MyBatis–>MyBatis Generator Configuration File

文件配置如下:

<?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:\user\681487\.m2\repository\mysql\mysql-connector-java\5.1.31\mysql-connector-java-5.1.31.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://10.118.46.20:3306/CONS" userId="mysql" password=""/>
<!-- 生成实体类 实体bean文件 -->
<javaModelGenerator targetPackage="com.sf.hbms.cons.domain" targetProject="HBMS-CONS" />
<!-- mapper xml文件 -->
<sqlMapGenerator targetPackage="com.sf.hbms.cons.persistence" targetProject="HBMS-CONS" />
<!-- mapper 接口文件 -->
<javaClientGenerator targetPackage="com.sf.hbms.cons.persistence" targetProject="HBMS-CONS" type="XMLMAPPER" />
<!-- 数据库的表 -->
<table schema="ConsOrder"  tableName="cons_order" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" ></table>
<table schema="OonsOrderOsyncresult"  tableName="cons_order_asyncresult" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" ></table>
<table schema="ConsOrderDetail"  tableName="cons_order_detail" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" ></table>
<table schema="ConsOrderPay"  tableName="cons_order_pay" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" ></table>
<table schema="ConsOrderReqresp"  tableName="cons_order_reqresp" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" ></table>
<table schema="ConsProducts"  tableName="cons_products" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" ></table>

<table schema="InThirdOrder"  tableName="in_third_order" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" ></table>
</context>
</generatorConfiguration>


5、Eclipse中右键generatorConfigure.xml文件,执行性:Generate MyBatis /iBATIS Artifacts,即可生成对应文件。

6、参考链接:http://jingyan.baidu.com/article/9faa7231506ed8473c28cbee.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: