Ibatis automatic generation of DAO Sqlmapper files and domain file procedures

Source: Internet
Author: User

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
 
  
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE generatorConfiguration PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN" "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd" >
  3. <generatorConfiguration>
  4. <classPathEntry location="D:\apache-tomcat-7.0.52\webapps\traceSys\WEB-INF\lib\mysql-connector-java-5.1.29.jar" />
  5. span class= "tag" ><context id = "context1" >
  6. span class= "tag" ><jdbcconnection driverclass = "com.mysql.jdbc.Driver" connectionurl = "Jdbc:mysql://localhost:3306/trace_sys" userid = "root" password = />
  7. <javaModelGenerator targetPackage="com.trace.domain"
  8. targetProject="D:\cpn-work\traceSys\src\main\java" />
  9. <sqlMapGenerator targetPackage="com.trace.dao" targetProject="D:\cpn-work\traceSys\src\main\java"></sqlMapGenerator>
  10. <javaClientGenerator targetPackage="com.trace.dao"
  11. Span class= "ATN" >targetproject = "D:\cpn-work\traceSys\src\main \java " type = "Xmlmapper" />
  12. <table < span> tablename = "Company" enablecountbyexample = "False" enableupdatebyexample = enabledeletebyexample = enableselectbyexample = "False" selectbyexamplequeryid = />
  13. <table < span> tablename = "goods" enablecountbyexample = "False" enableupdatebyexample = enabledeletebyexample = enableselectbyexample = "False" selectbyexamplequeryid = />
  14. <table < span> tablename = "Goods_discuss" Span class= "PLN" > enablecountbyexample = enableupdatebyexample = "False" enabledeletebyexample = enableselectbyexample = selectbyexamplequeryid = "False" />
  15. <table < span> tablename = "goods_production" enablecountbyexample = "False" enableupdatebyexample = enabledeletebyexample = enableselectbyexample = "False" selectbyexamplequeryid = />
  16. <table < span> tablename = "Goods_profile" Span class= "PLN" > enablecountbyexample = enableupdatebyexample = "False" enabledeletebyexample = enableselectbyexample = selectbyexamplequeryid = "False" />
  17. <table < span> tablename = "Goods_record" Span class= "PLN" > enablecountbyexample = enableupdatebyexample = "False" enabledeletebyexample = enableselectbyexample = selectbyexamplequeryid = "False" />
  18. <table < span> tablename = "type" enablecountbyexample = "False" enableupdatebyexample = enabledeletebyexample = enableselectbyexample = "False" selectbyexamplequeryid = />
  19. <table < span> tablename = "user" enablecountbyexample = "False" enableupdatebyexample = enabledeletebyexample = enableselectbyexample = "False" selectbyexamplequeryid = />
  20. </context>
  21. </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
  
  1. 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.