ibator使用

一、ibator是一个ibatis的代码生成工具,它能根据数据表自动生成javabean、sqlmap。

ibator的官方地址是 http://ibatis.apache.org/ibator.html

二、在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。

配置文件abatorConfig.xml

Tip配置文件里不要有注释,会报不能解析‘--’字符错误。

<?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>  
  
    <jdbcConnection driverClass="oracle.jdbc.driver.OracleDriver" connectionURL="jdbc:oracle:thin:@22.188.xxx.xxx:1521:oraGCSC" userId="test" password="123" >  
    <classPathEntry location="E:ojdbc14.jar" />  
    </jdbcConnection>  
    
    <javaModelGenerator targetPackage="com.xxx.monitor.dailyStatis.model" targetProject="XXX-TRACESTATISTICS" />  
    
    <sqlMapGenerator targetPackage="com.xxx.monitor.dailyStatis.mapper" targetProject="XXX-TRACESTATISTICS" />
      
    <daoGenerator targetPackage="com.xxx.monitor.dailyStatis.dao" targetProject="XXX-TRACESTATISTICS" type="GENERIC-CI" />  
    
    <table schema="" tableName="MONITOR_T_STA_TRACEDAILY" domainObjectName="StaTraceDaily"
    enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false"
    enableSelectByExample="false" selectByExampleQueryId="false">    </table>  
    
    <table schema="" tableName="MONITOR_T_STA_SUMTRACECOUNT" domainObjectName="StaSumTraceCount"
    enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false"
    enableSelectByExample="false" selectByExampleQueryId="false">    </table>  
    
  </abatorContext>  
</abatorConfiguration>

ibator默认生成的文件中有一堆无用注释,影响阅读。

ibator的注释全部放在DefaultCommentGenerator类里,所以直接把它所有的方法全注释掉了。编译后,替代jar包的中class文件。

jar包路径:eclipsepluginsorg.apache.ibatis.abator.core_1.1.0下面的abator.jar。

原文地址:https://www.cnblogs.com/amunamuna/p/8573478.html