首页 > 其他 > 详细

mybatis-generator-xxxx 使用方法

时间:2018-01-13 17:54:24      阅读:200      评论:0      收藏:0      [点我收藏+]

mybatis-generator 下载

自动生成mapper.xml.mapper.java,javabean

官网下载:http://blog.mybatis.org/

下载完成后目录

技术分享图片

进入到lib目录下,加入mysql驱动jar包,创建src文件夹,创建generatorConfig.xml文件

在generatorConfig.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>

  <!--MySQL连接驱动注意版本-->
  <classPathEntry location="mysql-connector-java-5.1.9.jar" />
  
  <!--数据库链接URL,用户名、密码 -->
  <context id="MySQL" targetRuntime="MyBatis3">
    <commentGenerator>  
            <property name="suppressDate" value="true"/>  
            <!-- 是否去除自动生成的注释 true:是 : false:否 -->  
            <property name="suppressAllComments" value="true"/>  
    </commentGenerator> 
    <jdbcConnection driverClass="com.mysql.jdbc.Driver"
        connectionURL="jdbc:mysql://127.0.0.1/hrs"
        userId="root"
        password="123456">
    </jdbcConnection>

    <!--是否启用java.math.BigDecimal-->
    <javaTypeResolver >
      <property name="forceBigDecimals" value="false" />
    </javaTypeResolver>

    <javaModelGenerator targetPackage="test.model" targetProject="src">
      <property name="enableSubPackages" value="true" />
      <property name="trimStrings" value="true" />
    </javaModelGenerator>

    <sqlMapGenerator targetPackage="test.xml"  targetProject="src">
      <property name="enableSubPackages" value="true" />
    </sqlMapGenerator>

    <javaClientGenerator type="XMLMAPPER" targetPackage="test.dao"  targetProject="src">
      <property name="enableSubPackages" value="true" />
    </javaClientGenerator>

<!--表名 -->
    <table tableName="user" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false">
    </table>
    <table tableName="position" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false">
    </table>
    <table tableName="department" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false">
    </table>
  </context>
</generatorConfiguration>

  然后打开命令行

进去到lib目录下

然后输入

//注意mybatis-generator包版本和xml文件名字
java -jar mybatis-generator-core-1.3.2.jar -configfile generatorConfig.xml -overwrite

  技术分享图片

 

mybatis-generator-xxxx 使用方法

原文:https://www.cnblogs.com/durui/p/8279885.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!