Ibatis code automatic generation tool--Abator plugin

 Abator can automatically generate Dao, Dto and sqlMap, which greatly improves development efficiency.

      Abator's official website: http://ibatis.apache.org/ibator.html   (this URL is no longer available)

 

     The following describes how to install the Abator plug-in in Eclipse:

 

1、点击"Help>Install New Software"

 

Enter url:  http://ibatis.apache.org/tools/abator



 

2. After the installation is complete, restart the plug-in to see the effect of the plug-in



 

3. Click Abator for iBATIS Configuration File and select the project location


 

4. Click Finish to see as shown below

 

 

The default content of abatorConfig.xml file is:

 

Xml code   Favorite code
  1. <?xml version="1.0" encoding="UTF-8" ?>  
  2. <!DOCTYPE abatorConfiguration PUBLIC "-//Apache Software Foundation//DTD Abator for iBATIS Configuration 1.0//EN" "http://ibatis.apache.org/dtd/abator-config_1_0.dtd" >  
  3. <abatorConfiguration >  
  4.   <abatorContext >  
  5.     <jdbcConnection driverClass="???" connectionURL="???" userId="???" password="???" >  
  6.       <classPathEntry location="???" />  
  7.     </jdbcConnection>  
  8.     <javaModelGenerator targetPackage="???" targetProject="???" />  
  9.     <sqlMapGenerator targetPackage="???" targetProject="???" />  
  10.     <daoGenerator targetPackage="???" targetProject="???" type="GENERIC-CI" />  
  11.     <table schema="???" tableName="???" >  
  12.       <columnOverride column="???" property="???" />  
  13.     </table>  
  14.   </abatorContext>  
  15. </abatorConfiguration>  

 

 

4. Replace the ??? in abatorConfig.xml:

a) Fill in driverClass (jdbc driver, such as oracle.jdbc.driver.OracleDriver) 
b) Fill in connectionURL (connection string, such as oracle is jdbc:oracle:thin:@localhost:1521:orcl) 
c) Fill in classPathEntry location (the location of the jdbc driver jar package, such as D:/myproject/test/WEB-INF/lib/ojdbc14.jar)
d) Fill in the javaModelGenerator, the generated DTO (java model class) 
targetPackage: the location of the target package, such as com .test.model
targetProject: target project name, fill in the eclipse project name where the configuration file is located, such as test/src
e) fill in sqlMapGenerator, the related configuration of the generated xml sqlmap 
targetPackage: target location, such as com.test.sqlmap 
targetProject: target project Name, fill in the eclipse project name where the configuration file is located, such as test/src
f) Fill in daoGenerator, the related configuration of the generated DAO 
type: the type of the generated dao implementation, if you use spring, write SPRING, otherwise write IBATIS 
targetPackage: target location , such as com.test.dao 
targetProject: target project name, fill in the eclipse project name where the configuration file is located, such as test/src
g) Configure the table of the relevant database 
schema: database schema, oracle is to fill in the user name of the database, such as test
tableName: indicates, such as ttest
catalog: database name, such as orcl
comment out <columnOverride column="???" property="???" />, no Write columnOverride to generate all fields

 

The replaced files are as follows (the encoding here is changed to GBK, because it is related to the author's development environment and has nothing to do with the subsequent results):

Xml code   Favorite code
  1. <?xml version="1.0" encoding="GBK" ?>  
  2. <!DOCTYPE abatorConfiguration PUBLIC "-//Apache Software Foundation//DTD Abator for iBATIS Configuration 1.0//EN" "http://ibatis.apache.org/dtd/abator-config_1_0.dtd" >  
  3. <abatorConfiguration >  
  4.   <abatorContext >  
  5.     <jdbcConnection driverClass="oracle.jdbc.driver.OracleDriver" connectionURL="jdbc:oracle:thin:@localhost:1521:test" userId="test" password="test" >  
  6.       <classPathEntry location="E:\其他\maven-repository\com\oracle\ojdbc6\11.2.0.3.0\ojdbc6-11.2.0.3.0.jar" />  
  7.     </jdbcConnection>  
  8.     <javaModelGenerator targetPackage="com.test.model" targetProject="IbatisGenetor/src" />  
  9.     <sqlMapGenerator targetPackage="com.test.sqlmap" targetProject="IbatisGenetor/src" />  
  10.     <daoGenerator targetPackage="com.test.dao" targetProject="IbatisGenetor/src" type="SPRING" />  
  11.     <!--<daoGenerator targetPackage="com.test.dao" targetProject="IbatisGenetor/src" type="IBATIS" />-->  
  12.     <table schema="" tableName="T_INSURANCE" >  
  13.       <!--<columnOverride column="???" property="???" />-->  
  14.     </table>  
  15.   </abatorContext>  
  16. </abatorConfiguration>  

 

 

5. Right-click the abtorConfig.xml file and select Generate iBATIS Artifacts



 

6. The relevant code is automatically generated here.

 

 

api:http://ibatis.apache.org/docs/tools/abator/

Reprinted from: http://zhuchengzzcc.iteye.com/blog/1817778
 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326226138&siteId=291194637