ibatis代码生成工具abator使用全过程
*******************************************************
1) 下载网站,按以下步骤安装
*****************************************************
http://ibatis.apache.org/abator.html
Manual Eclipse Install
The automatic install is much preferred, but you can also install Abator manually if you desire. To install manually, download the file AbatorForEclipse1.0.0.zip and unzip the file to some convenient location. This file is a zipped version of the update site and includes both version 1.0.0, and the prior version 0.6.5. After unzipping the update site archive, follow these steps in Eclipse:
1. Take the "Help>Software Updates>Find and Install" Menu Option
2. Select the "Search for new features to install" radio button, press "Next"
3. Press the "New Local Site" button
4. Navigate to the location where you unzipped the file.
5. Press OK
6. Follow the remainder of the install wizard
****************************************
2)配置abator ----------abatroConfig.xml
********************************
新建一种文件类型:Abator for iBATIS Configuration File
当前项目下生成abatroConfig.xml文件;
-------------------abatroConfig.xml---------------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE abatorConfiguration PUBLIC "-//Apache Software Foundation//DTD Abator for iBATIS Configuration 1.0//EN"
"http://ibatis.apache.org/dtd/abator-config_1_0.dtd">
<abatorConfiguration>
<abatorContext> <!-- TODO: Add Database Connection Information -->
<jdbcConnection driverClass="com.mysql.jdbc.Driver"
connectionURL="jdbc:mysql://127.0.0.1:3306/ctwob"
userId="root"
password="fu">
<classPathEntry location="E:\2007new\eclipse\workspace\c2bend\WebRoot\WEB-INF\lib\mysql-connector-java-3.1.8-bin.jar" />
</jdbcConnection>
<javaModelGenerator targetPackage="com.qq.model" targetProject="c2bend" />
<sqlMapGenerator targetPackage="com.qq.xml" targetProject="c2bend" />
<daoGenerator type="IBATIS" targetPackage="com.qq.dao" targetProject="c2bend" />
<table schema="first" tableName="ask">
</table>
</abatorContext>
</abatorConfiguration>
节点说明:
<jdbcConnection
driverClass="com.mysql.jdbc.Driver" /***driverClass驱动类型 为mysql
connectionURL="jdbc:mysql://127.0.0.1:3306/ctwob" /****connectionURL为 mysql 数据库为ctwob
userId="root" /**用户名
password="fuzhou708"> /**密码
<classPathEntry location= /**mysql的jdbc类包 mysql-connector-java-3.1.8-bin.jar
"E:\2007new\eclipse\workspace\c2bend\WebRoot\WEB-INF\lib\mysql-connector-java-3.1.8-bin.jar" />
</jdbcConnection>
4:在 jdbcConnection 中设置要mapping的数据库的jdbc连接
classPathEntry 是你的jdbc driver类路径
5:javaModelGenerator,sqlMapGenerator,daoGenerator 分别设置 java dataObject、sql mapping文件和 DAO 接口、实现类的生成位置:targetPackage 目标包,targetProject:eclipse项目
6:daoGenerator 中可以设置属性 type: ibatis 或 spring 指定生成的dao实现类是使用com.ibatis.dao.client.template.SqlMapDaoTemplate
还是org.springframework.orm.ibatis.support.SqlMapClientDaoSupport
7: table 中 tableName 指定要处理的表名
可以有多个table
8:table中可以包含子元素 generatedKey: 使Insert方法可以返回值--由指定的column mapping
9:generatedKey中的sqlStatement属性可以是获取sequence的SQL,也可以是获取自增值的SQL
比如:Oracle的 select theSequence.nextVal from dual
SQLServer的 SELECT @@IDENTITY as column_name
-------------------------------------------------
*************************
3)保存文件,选中文件,右键菜单选择Generate iBATIS Artifacts! ok..
********************************
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· [.NET]调用本地 Deepseek 模型
· 一个费力不讨好的项目,让我损失了近一半的绩效!
· .NET Core 托管堆内存泄露/CPU异常的常见思路
· PostgreSQL 和 SQL Server 在统计信息维护中的关键差异
· C++代码改造为UTF-8编码问题的总结
· 一个费力不讨好的项目,让我损失了近一半的绩效!
· 清华大学推出第四讲使用 DeepSeek + DeepResearch 让科研像聊天一样简单!
· 实操Deepseek接入个人知识库
· CSnakes vs Python.NET:高效嵌入与灵活互通的跨语言方案对比
· Plotly.NET 一个为 .NET 打造的强大开源交互式图表库