Ibatis自动生成dao sqlmapper文件和domain文件过程
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包。

3、编写genertor的xml文件,名下: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" />
<context id="context1">
<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"
targetProject="D:\cpn-work\traceSys\src\main\java" type="XMLMAPPER" />
<table tableName="company" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" />
<table tableName="goods" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" />
<table tableName="goods_discuss" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" />
<table tableName="goods_production" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" />
<table tableName="goods_profile" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" />
<table tableName="goods_record" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" />
<table tableName="type" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" />
<table tableName="user" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" />
</context>
</generatorConfiguration>
enableCountByExample="false"
enableUpdateByExample="false"
enableDeleteByExample="false"
enableSelectByExample="false"
selectByExampleQueryId="false"
schema即为数据库名, tableName为对应的数据库表, domainObjectName是要生成的实体类,
如果想要mapper配置文件加入sql的where条件查询, 可以将enableCountByExample等设为true,
这样就会生成一个对应domainObjectName的Example类, enableCountByExample等设为false时,
就不会生成对应的Example类了.
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
Ibatis自动生成dao sqlmapper文件和domain文件过程的更多相关文章
- iBatis——自动生成DAO层接口提供操作函数(详解)
iBatis——自动生成DAO层接口提供操作函数(详解) 在使用iBatis进行持久层管理时,发现在使用DAO层的updateByPrimaryKey.updateByPrimaryKeySelect ...
- 【Java MyBatis Generator】使用generator自动生成Dao,Mapping和实体文件
具体请参照: http://blog.csdn.net/fengshizty/article/details/43086833 按照上面博客地址,下载Generator的依赖包: 如下是我的配置文件: ...
- Mybatis-Generator插件自动生成Dao、Model、Mapping相关文件
最近做项目,mapping 有点多而且容易写错,于是试着用了Mybatis-Generator 插件自动生成 dao, domain mapping 文件.感觉还挺好用.把相关配置分享,一边以后做项 ...
- 使用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相关文件(转)
- Mybatis-Generator 自动生成Dao、Model、Mapping相关文档
最近在学习mybatis,结果在写Mapping的映射文件时insert语句一直报错,于是想看看标准的映射文件是什么样.百度到Mybatis-Generator 自动生成Dao.Model.Mappi ...
- T4 模板自动生成带注释的实体类文件
T4 模板自动生成带注释的实体类文件 - 只需要一个 SqlSugar.dll 生成实体就是这么简单,只要建一个T4文件和 文件夹里面放一个DLL. 使用T4模板教程 步骤1 创建T4模板 如果你没有 ...
- IDEA利用mybatis-generator自动生成dao和mapper
pom.xml配置 <properties> <java.version>1.8</java.version> <mybatis-generator-core ...
- ibatis 自动生成map,bean,dao
1.下载 AbatorForEclipse1.1.0 地址:http://download.csdn.net/detail/fym548/9426877 点击Archive按钮选择下载的,然后重启My ...
- 使用mybatis generator插件,自动生成dao、dto、mapper等文件
mybatis generator 介绍 mybatis generator中文文档http://mbg.cndocs.tk/ MyBatis Generator (MBG) 是一个Mybatis的代 ...
随机推荐
- addEventListener与removeEventListener
addEventListener:添加事件监听器 element.addEventListener(event, function, useCapture) event:事件类型,字符串,不要加&qu ...
- ElasticSearch — 集群搭建
1.es需要java环境,故先检查java环境是否正常 2.下载elasticsearch安装包 http://www.elasticsearch.org/download/ 目前最新版本到1.4.0 ...
- ExtJS3.4升级ExtJS4.2的问题汇总(转)
ExtJS3.4升级ExtJS4.2的问题汇总 昨天心血来潮,想把自己用extjs3.4作为UI的一个原型升级到最新的extjs4.2.2. 几年前曾经将原型从2.1升级到3.4,对于extjs的版本 ...
- Adobe Acrobat 9 Pro 注册码
来自百度知道,记录与此,以备后用http://zhidao.baidu.com/question/177914535.html 如果你的系统盘是C盘,那么就删除:c:/Documents and Se ...
- PAT1005
水题,和中文没啥区别不说了. #include<cstdio> #include<cstdlib> #include<iostream> #include<a ...
- 向页面动态添加外部js
var script = document.createElement("script"); script.src = '/static/js/view/'+url+'.js'; ...
- 改写BlogEngine.NET头像上传实现方式(使用baidu.flash.avatarMaker)
baidu.flash.avatarMaker 需要资源文件和javascript类库: 1 2 3 4 5 6 7 需要应用的script library: <scriptsrc=" ...
- 表单提交中记得form表单放到table外面
帝国后台按栏目搜索文章时怎么都不生效 控制台查看原来是 栏目的select的值没有提交过去,原来由于form标签在table标签里面,导致js生成的<select>标签提交失败. 解决办 ...
- 集合问题 离线+并查集 HDU 3938
题目大意:给你n个点,m条边,q个询问,每条边有一个val,每次询问也询问一个val,定义:这样条件的两个点(u,v),使得u->v的的价值就是所有的通路中的的最长的边最短.问满足这样的点对有几 ...
- Android Screen Monitor使用
Android Screen Monitor的使用 用来把android手机屏幕投射到电脑屏幕上,能够放大缩小屏幕,与手机屏幕保持同步. 这个项目是一个开源项目,源码地址:https://code.g ...