generator自动生成mybatis的xml配置、model、map等信息: 
1、下载mybatis-generator-core-1.3.2.jar包。 
       网址:http://code.google.com/p/mybatis/downloads/list?can=3&q=Product%3DGenerator,下载mybatis-generator-core-1.3.2-bundle.zip,解压 
       找到lib下的需要jar包。 

2、新建工程项目
 
3、编写genertor的xml文件,名下: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. <context id="context1">
  6. <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. targetProject="D:\cpn-work\traceSys\src\main\java" type="XMLMAPPER" />
  12. <table tableName="company" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" />
  13. <table tableName="goods" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" />
  14. <table tableName="goods_discuss" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" />
  15. <table tableName="goods_production" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" />
  16. <table tableName="goods_profile" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" />
  17. <table tableName="goods_record" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" />
  18. <table tableName="type" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" />
  19. <table tableName="user" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" />
  20. </context>
  21. </generatorConfiguration>
table其他属性: 
enableCountByExample="false" 
enableUpdateByExample="false" 
enableDeleteByExample="false" 
enableSelectByExample="false" 
selectByExampleQueryId="false" 
schema即为数据库名, tableName为对应的数据库表, domainObjectName是要生成的实体类, 
如果想要mapper配置文件加入sql的where条件查询, 可以将enableCountByExample等设为true, 
这样就会生成一个对应domainObjectName的Example类, enableCountByExample等设为false时, 
就不会生成对应的Example类了. 


4、命令行方式生成
  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
成功时输出:MyBatis Generator finished successfully. 




最新文章

  1. Python 之 装饰器的写法
  2. 使用yum安装应用程序时候,报错:[Errno 14] PYCURL ERROR 7 - &quot;Failed to connect to 2001:da8:8000:6023::230: 网络不可达&quot;
  3. Hibernate检索策略之延迟加载和立即加载
  4. java中getBytes方法可能使图片文件产生的问题
  5. 浅谈HTTP响应拆分攻击
  6. [DP] LCS小结
  7. iOS UIKit:animation
  8. VSFTP被动模式
  9. 使用Xshell生成key,避免password登录linux
  10. Linux内核和根文件系统引导加载程序
  11. AngularJS最理想开发工具WebStorm
  12. MyEclipse 10 报错记录
  13. 前端(各种demo)一:css实现三角形,css实现梯形,pop弹层,css伪类before,after使用,svg使用(持续更新中)
  14. 王之泰《面向对象程序设计(java)》课程学习总结
  15. angularJS 路由加载js controller 未定义 解决方案
  16. 2018-7-17-随笔-params和ref、out用法、事件访问器
  17. 个人对vuex的表象理解(笔记)
  18. HanLP分词命名实体提取详解
  19. Delphi Language Overview
  20. Servlet的复习

热门文章

  1. NavigationBar的显隐和颜色设置
  2. C# 实现屏幕键盘 (ScreenKeyboard)
  3. Python定制类
  4. shell注意事项
  5. 快学scala-第七章 包和引入
  6. HDU1896Stones(优先队列)
  7. 常用的JS页面跳转代码调用大全
  8. struts体系结构
  9. JavaScript返回上一页并自动刷新
  10. JSP文件上传--FileUpload组件