mybatis generator eclipse插件的安装

来源:互联网 发布:阶乘c语言编程 编辑:程序博客网 时间:2024/06/07 01:48

目的:使用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>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30

5、Eclipse中右键generatorConfigure.xml文件,执行性:Generate MyBatis /iBATIS Artifacts,即可生成对应文件。 
6、参考链接:http://jingyan.baidu.com/article/9faa7231506ed8473c28cbee.html