myEclipse 安装ibatis插件

一.安装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。

二.建立一个项目
   新建一个Eclipse项目,输入名字,然后选择文件>新建>ABator for iBatis configuration File,选择Location,并且键入File Name:abatorCsonfig.xml。

点击“完成”,Eclipse会在程序根目录下建立abatorCsonfig.xml文件,打开编辑它,内容如下:

<?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="驱动" connectionURL="数据库URL" userId="用户名" password="密码" >
      <classPathEntry location="数据库驱动jar包" />
    </jdbcConnection>
    <javaModelGenerator targetPackage="model层包路径" targetProject="src路径" />
    <sqlMapGenerator targetPackage="map层包路径" targetProject="src路径" />
    <daoGenerator targetPackage="dao层包路径" targetProject="src路径" type="IBATIS" />
    <table schema="表名" tableName="表名" catalog="数据库名">一定要写上,不然会报错的。
    
    </table>
  </abatorContext>
</abatorConfiguration>

在abatorCsonfig.xml上点击鼠标右键,选择Generate iBATIS Artifact,在src目录下会生成model、map、dao三个目录,文件也建立好了。
 javaModelGenerator:我们常说的ValueObject
 sqlMapGenerator:XML文件
daoGenerator:放置接口和DAO的代码

如:

 <?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="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://127.0.0.1:3306/webbas?characterEncoding=gbk" userId="root" password="111111" >
      <classPathEntry location="E:/chenweixian/workspace20120309/generalIbatisCode/WebRoot/WEB-INF/lib/mysql-connector-java-5.1.16-bin.jar" />
    </jdbcConnection>
    <javaModelGenerator targetPackage="com.chen.domain.bean" targetProject="generalIbatisCode" />
    <sqlMapGenerator targetPackage="com.chen.domain.dao.impl.ibatis" targetProject="generalIbatisCode" />
    <daoGenerator targetPackage="com.chen.domain.dao" targetProject="generalIbatisCode" type="GENERIC-CI" />
    <table schema="aa" tableName="aa">
     
    </table>
  </abatorContext>
</abatorConfiguration>

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值