使用Eclipse(MyEclipse)+ abator自动生成iBatis代码

liuyacsdn 2011-11-23

一.安装插件Abator

AbatorforEclipseUpdateSite

ThisistheAbatorforEclipseupdatesite.Ifyou'renotsurewhatAbatoris,thenseethispagehttp://ibatis.apache.org/abator.html

Ifyou'vealreadyinstalledapriorversionofAbatorforEclipse,thensimplyruntheEclipseInstall/Updatetoolandanynewversionwillbefoundautomatically.

Ifyou'venotalreadyinstalledAbator,thenyoucanusethebuiltinEclipseinstallsupportbyfollowingthesesteps:

1.Takethe"Help>SoftwareUpdates>FindandInstall"MenuOption

2.Selectthe"Searchfornewfeaturestoinstall"radiobutton,press"Next"

3.Pressthe"NewRemoteSite"button

4.Enterthefollowinginformation:

Name:

AbatorforEclipseUpdateSite

URL:

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

5.PressOK

6.Checktheboxnextto"AbatorforEclipseUpdateSite"

7.Followtheremainderoftheinstallwizard

插件完成后,建立一个项目ibatisTest,然后选择文件>新建>ABatorforiBatisconfigurationFile,默认文件名,点击“完成”。修改刚才的文件abatorConfig.xml,把里面的相关“?”根据自己的实际情况替换如下,我的是这样的。

Xml代码

<?xmlversion="1.0"encoding="UTF-8"?>

<!DOCTYPEabatorConfigurationPUBLIC"-//ApacheSoftwareFoundation//DTDAbatorforiBATISConfiguration1.0//EN"

"http://ibatis.apache.org/dtd/abator-config_1_0.dtd">

<abatorConfiguration>

<abatorContext><!--TODO:AddDatabaseConnectionInformation-->

<jdbcConnectiondriverclass="oracle.jdbc.driver.OracleDriver"

connectionURL="jdbc:oracle:thin:@localhost:1521:orcl"

userid="spell"

password="spell">

<classPathEntrylocation="G:/techinfo/javaLib/DB_Jar/oracle/classes12.jar"/>

</jdbcConnection>

<javaModelGeneratortargetPackage="com.spell.model"targetProject="ibatisTest/src"/>

<sqlMapGeneratortargetPackage="com.spell.map"targetProject="ibatisTest/src"/>

<daoGeneratortype="IBATIS"targetPackage="com.spell.dao"targetProject="ibatisTest/src"/>

<tableschema="SPELL"tablename="members"catalog="members">

</table>

</abatorContext>

</abatorConfiguration>

5、在abatorConfig.xml上点击鼠标右键,选择GenerateiBATISArtifact,在src目录下会生成com.spell.model、com.spell.map、com.spell.dao三个目录,文件也建立好了。其他有什么要修改的就自己动手吧~~

相关推荐

兔子压倒窝边草 / 0评论 2013-07-26
蜀川居 / 0评论 2014-07-16