ibator使用心得(转)
转自:http://www.cnblogs.com/ego/archive/2010/10/02/1840749.html
ibator是一个ibatis的代码生成工具,它能根据数据表自动生成javabean、sqlmap。
ibator的官方地址是 http://ibatis.apache.org/ibator.html,目前ibator只支持ibatis2.x,而ibatis3.0还不支持。
?
在eclipse中安装ibator插件步骤:
1.在eclipse菜单中打开插件安装界面:Help -> Install New Software ...
2.Work With:http://ibatis.apache.org/tools/abator
3.按向导安装,具体步骤略
?
使用ibator:
1.在project中右键 New -> Other ...
2.Apache ibatis ibator下面的Apache ibatis ibator Configuration File
?
配置ibator:
ibatorConfig.xml文件内容,请注意classPathEntry、ibatorPlugin、jdbcConnection 的顺序:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE ibatorConfiguration PUBLIC "-//Apache Software Foundation//DTD Apache iBATIS Ibator Configuration 1.0//EN" "http://ibatis.apache.org/dtd/ibator-config_1_0.dtd" >
?
<ibatorConfiguration>
?<classPathEntry
??location="D:\project\src\Project\WebContent\WEB-INF\lib\sqljdbc.jar" />
?<ibatorContext id="Project">
??<ibatorPlugin
???type="org.apache.ibatis.ibator.plugins.RenameExampleClassPlugin">
???<property name="searchString" value="Example$" />
???<property name="replaceString" value="Repository" />
??</ibatorPlugin>
??<ibatorPlugin type="org.apache.ibatis.ibator.plugins.SerializablePlugin"></ibatorPlugin>
??<jdbcConnection driverpassword="sa" />
??<javaModelGenerator targetPackage="project.model"
???targetproject="Project" />
??<sqlMapGenerator targetPackage="project.dao.xml"
???targetproject="Project" />
??<daoGenerator targetPackage="project.dao"
???targetproject="Project" type="GENERIC-CI" />
???
??<table schema="" tableName="Staff" />
?</ibatorContext>
</ibatorConfiguration>
?
我不喜欢用Example命名,因此改为用Repository,你也可以改为Criteria。
?
去掉ibator的注释:
ibator的注释很讨厌,既嗦又没用,因此我修改了ibator的源码,把它的注释全去掉了。
ibator的注释全部放在DefaultCommentGenerator类里,我懒得分析谁调用了它,直接把它所有的方法全注释掉了(以彼之道,还施彼身)。
修改后的ibator.jar在我的附件里,用它代替eclipse\plugins\org.apache.ibatis.ibator.core_1.2.1下面的ibator.jar 即可。
ibator.rar