如何在Eclipse中安装和使用ibatis插件Abator
1、获得abator:
http://ibatis.apache.org/abator.html
Eclipse可以自动的进行Update获取此Plugin,官方的安装步骤
AutomaticEclipseInstall
Ifyou'vealreadyinstalledapriorversionofAbator,simplyruntheEclipseInstall/Updatetoolandthenewversionwillbefoundautomatically.
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
2、安装好后将在New菜单中看到一个新的文件类型AbatorforiBATISConfigurationFile,此是Abator的配置文件,配置文件的详细说明见http://ibatis.apache.org/docs/tools/abator/
3、新建一个配置文件,进行修改,根据自己的实际需求进行修改
关键点:
1)jdbcconnection,按照一般的配置即可,需要说明的是它需要指定访问JdbcDriver的classPathEntry,对于MsSqlServer而言,要将这三个jar文件均包含在内,否则会出现jdbc访问错误。
2)配置三个Pakage
3)配置表,此处需说明的是对于MsSqlServer不能写TableSchema,我初次指定TableSchema,结果未找到对应的表
简单的配置如下,复杂的见配置文件的详细说明。示例配置文件如下
<abatorConfiguration> <abatorContext> <!-- TODO: Add Database Connection Information --> <jdbcConnection driverClass="com.microsoft.jdbc.sqlserver.SQLServerDriver" connectionURL="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=whm;SelectMethod=cursor" userId="sa" password="sa"> <classPathEntry location="C:/Program Files/Apache Software Foundation/Tomcat 5.0/common/lib/mssqlserver.jar" /> <classPathEntry location="C:/Program Files/Apache Software Foundation/Tomcat 5.0/common/lib/msutil.jar" /> <classPathEntry location="C:/Program Files/Apache Software Foundation/Tomcat 5.0/common/lib/msbase.jar" /> </jdbcConnection> <javaModelGenerator targetPackage="com.dwerp.itatis.domain" targetProject="BhbManage" /> <sqlMapGenerator targetPackage="com.dwerp.itatis.persistence.xml" targetProject="BhbManage" /> <daoGenerator type="IBATIS" targetPackage="com.dwerp.itatis.persistence.sqlmapdao" targetProject="BhbManage" /> <table tableName="BHBGL"> </table> </abatorContext> </abatorConfiguration>
4、右键单击配置文件,点击GenerateiBatisArtifacts,生成文件。