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. 




Ibatis自动生成dao sqlmapper文件和domain文件过程的更多相关文章

  1. iBatis——自动生成DAO层接口提供操作函数(详解)

    iBatis——自动生成DAO层接口提供操作函数(详解) 在使用iBatis进行持久层管理时,发现在使用DAO层的updateByPrimaryKey.updateByPrimaryKeySelect ...

  2. 【Java MyBatis Generator】使用generator自动生成Dao,Mapping和实体文件

    具体请参照: http://blog.csdn.net/fengshizty/article/details/43086833 按照上面博客地址,下载Generator的依赖包: 如下是我的配置文件: ...

  3. Mybatis-Generator插件自动生成Dao、Model、Mapping相关文件

    最近做项目,mapping 有点多而且容易写错,于是试着用了Mybatis-Generator 插件自动生成 dao, domain  mapping 文件.感觉还挺好用.把相关配置分享,一边以后做项 ...

  4. 使用Mybatis-Generator自动生成Dao、Model、Mapping相关文件(转)-----https://www.cnblogs.com/smileberry/p/4145872.html

    https://www.cnblogs.com/smileberry/p/4145872.html 使用Mybatis-Generator自动生成Dao.Model.Mapping相关文件(转)

  5. Mybatis-Generator 自动生成Dao、Model、Mapping相关文档

    最近在学习mybatis,结果在写Mapping的映射文件时insert语句一直报错,于是想看看标准的映射文件是什么样.百度到Mybatis-Generator 自动生成Dao.Model.Mappi ...

  6. T4 模板自动生成带注释的实体类文件

    T4 模板自动生成带注释的实体类文件 - 只需要一个 SqlSugar.dll 生成实体就是这么简单,只要建一个T4文件和 文件夹里面放一个DLL. 使用T4模板教程 步骤1 创建T4模板 如果你没有 ...

  7. IDEA利用mybatis-generator自动生成dao和mapper

    pom.xml配置 <properties> <java.version>1.8</java.version> <mybatis-generator-core ...

  8. ibatis 自动生成map,bean,dao

    1.下载 AbatorForEclipse1.1.0 地址:http://download.csdn.net/detail/fym548/9426877 点击Archive按钮选择下载的,然后重启My ...

  9. 使用mybatis generator插件,自动生成dao、dto、mapper等文件

    mybatis generator 介绍 mybatis generator中文文档http://mbg.cndocs.tk/ MyBatis Generator (MBG) 是一个Mybatis的代 ...

随机推荐

  1. make TARGET_PRODUCT=am335xevm OMAPES=4.x rowboat_clean 出现sgx相关的错误

    这些错误是一些链接错误,由于地址变更导致的软链接不对.所以只要更改下软链接的具体地址就可以.

  2. ado vb6

    http://www.cnblogs.com/ywb-lv/articles/2343444.html http://stackoverflow.com/questions/3334102/use-t ...

  3. HttpWebRequest 抓取页面异常处理办法

    抓取页面异常处理办法 public static string GetHtmlTest(string URI) { string fullhtml = null; while (true) { try ...

  4. wpf之ListBox横向显示所有ListBoxItem

    Xaml: <Window x:Class="WpfApplication6.MainWindow" xmlns="http://schemas.microsoft ...

  5. oracle sqlplus @@用法

    本文章已收录于:   .embody { padding: 10px 10px 10px; margin: 0 -20px; border-bottom: solid 1px #ededed } .e ...

  6. API CLOUD 快捷键

    常用快捷键有:Ctrl+Z:撤销Ctrl+N:创建项目或文件Ctrl+Shift+F:代码格式化(这个经常用,可以美化代码,也可以通过这个检查代码是否出错)Ctrl+/ :注释和反注释Alt+/:强制 ...

  7. weak和assign区别

    weak比assign多了一个功能,当对象消失后自动把指针变成nil haofanazenmeban[4002:406590] controller:<SecondViewController: ...

  8. json对象的简单介绍

    1.JSON(JavaScript Object Notation)一种简单的数据格式,比xml更轻巧.JSON是JavaScript原生格式,这意味着在JavaScript中处理JSON数据不需要任 ...

  9. C --> OC with RunTime

    前言 本来打算写一篇关于runtime的学习总结,无奈长篇大论不是我的风格,就像写申论一样痛苦,加之网上关于tuntime的文章多如牛毛,应该也够童子们学习的了,今天就随便聊聊我的理解吧. runti ...

  10. iOS拨打电话(三种方法)

    iOS拨打电话(三种方法)  查了很多地方的关于iOS程序拨打电话,大都不全,今天我总结了三种方法,各有不同,拿来给大家分享,希望给大家有所帮助 1,这种方法,拨打完电话回不到原来的应用,会停留在通讯 ...