mybatis generator用法

1.建好数据库

2.下载

http://blog.mybatis.org/p/products.html

3.取出jar包

mybatis-generator-core-1.3.2.jar

4.建造好生成目录

5.参照下载下来的docs里的文档 写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="C:\Users\akishimo\.m2\repository\mysql\mysql-connector-java\5.1.28\mysql-connector-java-5.1.28.jar" />

  <context id="DB2Tables" targetRuntime="MyBatis3">
    <jdbcConnection driverClass="com.mysql.jdbc.Driver"
        connectionURL="jdbc:mysql://localhost:3306/test"
        userId="root"
        password="root">
    </jdbcConnection>

    <javaTypeResolver >
      <property name="forceBigDecimals" value="false" />
    </javaTypeResolver>

    <javaModelGenerator targetPackage="model" targetProject="E:\tools\testGenerate\src">
      <property name="enableSubPackages" value="true" />
      <property name="trimStrings" value="true" />
    </javaModelGenerator>

    <sqlMapGenerator targetPackage="mapping"  targetProject="E:\tools\testGenerate\src">
      <property name="enableSubPackages" value="true" />
    </sqlMapGenerator>

    <javaClientGenerator type="XMLMAPPER" targetPackage="dao"  targetProject="E:\tools\testGenerate\src">
      <property name="enableSubPackages" value="true" />
    </javaClientGenerator>

    <table tableName="user" domainObjectName="User" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>

  </context>
</generatorConfiguration>


6.执行命令

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

 

posted @ 2014-01-11 18:04  Akishimo  阅读(523)  评论(0编辑  收藏  举报