MyEclipse下怎么安装和使用ibatis插件
MyEclipse下如何安装和使用ibatis插件
(1)myeclipse→help→Myeclipse configuration center:点击sofeware选项卡,在Browes Software 下
有一个输入框,点击add site按钮:Name输入 Abator,URL输入 http://ibatis.apache.org/tools/abator
;
(2)稍等一会,在Personal Sites下就会列出Abator相应的版本,点击相应版本前面的加号,在abator
Code Generator to iBATIS上点右键,选择Add to profile...就自动进行安装;
(3)安装完成后会提示是否重启,点击确定。重启myeclipse后,File→New→Abator for iBATIS
Configuration File;
(4)在Location中输入项目名:Proj_IbatisTest,在File name中输入:abatorConfig.xml;
(5)修改abatorConfig.xml文件,将对应的数据库信息和表信息填充。然后右击项目下的该文件,选择
Generate iBATIS Artifacts,就会自动生成对应的dao,model,sqlmap。
<?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:@localhost:1521:orcl" userId="scott" password="tgl" > <classPathEntry location="E:/java/jar/classes12.jar" /> </jdbcConnection> <!-- model配置 --> <javaModelGenerator targetPackage="com.domian" targetProject="ibatis\src"> <property name="enableSubPackages" value="true" /> <property name="trimStrings" value="true" /> </javaModelGenerator> <sqlMapGenerator targetPackage="com.domian" targetProject="ibatis\src\"> <property name="enableSubPackages" value="true" /> <property name="trimStrings" value="true" /> </sqlMapGenerator> <table tableName="EMP" domainObjectName="Emp"> <generatedKey column="EMPNO" identity="true" sqlStatement="select p.nextval from dual"/> <columnOverride column="EMPNO" property="empno" javaType="int" jdbcType="int"/> </table> <table tableName="DEPT" domainObjectName="dept"> <generatedKey column="DEPTNO" identity="true" sqlStatement="select p.nextval from dual"/> <columnOverride column="DEPTNO" property="deptno" javaType="int" jdbcType="int"/> </table> </abatorContext> </abatorConfiguration>