generator automatically generates mybatis XML configuration, model, map, and other information:
1, download Mybatis-generator-core-1.3.2.jar package.
Website: http://code.google.com/p/mybatis/downloads/list?can=3&q=Product%3DGenerator, Download Mybatis-generator-core-1.3.2-bundle.zip, unzip
Find the required jar package under LIB. 2. New Project
3, write the genertor XML file name: 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="D:\apache-tomcat-7.0.52\webapps\traceSys\WEB-INF\lib\mysql-connector-java-5.1.29.jar" />
span class= "tag" ><context id = "context1" >
span class= "tag" ><jdbcconnection driverclass = "com.mysql.jdbc.Driver" connectionurl = "Jdbc:mysql://localhost:3306/trace_sys" userid = "root" password = />
<javaModelGenerator targetPackage="com.trace.domain"
targetProject="D:\cpn-work\traceSys\src\main\java" />
<sqlMapGenerator targetPackage="com.trace.dao" targetProject="D:\cpn-work\traceSys\src\main\java"></sqlMapGenerator>
<javaClientGenerator targetPackage="com.trace.dao"
Span class= "ATN" >targetproject = "D:\cpn-work\traceSys\src\main \java " type = "Xmlmapper" />
<table < span> tablename = "Company" enablecountbyexample = "False" enableupdatebyexample = enabledeletebyexample = enableselectbyexample = "False" selectbyexamplequeryid = />
<table < span> tablename = "goods" enablecountbyexample = "False" enableupdatebyexample = enabledeletebyexample = enableselectbyexample = "False" selectbyexamplequeryid = />
<table < span> tablename = "Goods_discuss" Span class= "PLN" > enablecountbyexample = enableupdatebyexample = "False" enabledeletebyexample = enableselectbyexample = selectbyexamplequeryid = "False" />
<table < span> tablename = "goods_production" enablecountbyexample = "False" enableupdatebyexample = enabledeletebyexample = enableselectbyexample = "False" selectbyexamplequeryid = />
<table < span> tablename = "Goods_profile" Span class= "PLN" > enablecountbyexample = enableupdatebyexample = "False" enabledeletebyexample = enableselectbyexample = selectbyexamplequeryid = "False" />
<table < span> tablename = "Goods_record" Span class= "PLN" > enablecountbyexample = enableupdatebyexample = "False" enabledeletebyexample = enableselectbyexample = selectbyexamplequeryid = "False" />
<table < span> tablename = "type" enablecountbyexample = "False" enableupdatebyexample = enabledeletebyexample = enableselectbyexample = "False" selectbyexamplequeryid = />
<table < span> tablename = "user" enablecountbyexample = "False" enableupdatebyexample = enabledeletebyexample = enableselectbyexample = "False" selectbyexamplequeryid = />
</context>
</generatorConfiguration>
Table Other properties:
Enablecountbyexample= "false"
Enableupdatebyexample= "false"
Enabledeletebyexample= "false"
Enableselectbyexample= "false"
Selectbyexamplequeryid= "false"
The schema is the database name, TableName is the corresponding database table, Domainobjectname is the entity class to be generated,
If you want the mapper configuration file to join the SQL where condition query, you can set enablecountbyexample and so on to true,
This generates a example class corresponding to the Domainobjectname, Enablecountbyexample, and so on, when set to false.
The corresponding example class is not generated.
4, command-line mode generation
Java-jar E:\websoft\mybaits\mybatis-Generator-Core-1.3.2\lib\mybatis-Generator-Core-1.3.2.jar -configfile E:\webworkspace\workspace_js\downattachdemo\src\com\mochasoft\down\generator.XML-Overwrite
Successful output: MyBatis Generator finished successfully.
From for notes (Wiz)
Ibatis automatic generation of DAO Sqlmapper files and domain file procedures