Ibator生成ibatis 配文件

Ibato r 生成ibatis 配置文件

 

作者:×××

日期:2009-06-08 15.03

版本:0.1

Ibator能给我们带来什么

由于使用Ibatis 时需要生成的配置文件较多,而且对于字段较多的表生成其 Ibatis 实体时容易出错,使用 Ibators 插件能减少我们很多枯燥的工作,提高正确性和准确率。

准备工作

Eclipse Platform   Version: 3.4.2 ;

Ibator官方网站 Ibator: 1.2.1 ;

安装Ibator 插件,可以使用本地方式安装,也可以使用 Update side 方式安装,为了方便,这里使用 update side 方式安装(引自官网):

Automatic Eclipse Install

If you've already installed a prior version of Ibator, simply run the Eclipse Update tool and the new version will be found automatically.

If you've not previously installed Ibator, use the built in Eclipse install support by following these steps:

1.  Take the "Help>Software Updates..." Menu Option

2.  Select the "Available Software" Tab

3.  Press the "Add Site" button

4.  Enter the following information: Location,http://ibatis.apache.org/tools/ibator

5.  Press OK

6.  Check the box next to "Apache iBATIS Ibator Feature"

7.  Press the "Install" button

8.  Follow the remainder of the install wizard (restart you eclipse IDE)

插件安装成功之后,

在“File->New ”菜单里将会有一个新选项,如下图:

在鼠标右键上,也会有一个新的选项,如下图:

示例

步骤如下:

1.  生成ibatorConfig.xml 配置文件,关于配置文件详细注释参见: Introduction to Abator

2.  配置数据库连接(驱动,URLUserPsdetc );

3.  配置Java Model Generator 参数;

4.  配置SQL Map Generator 参数;

5.  配置DAO Generator 参数;

6.  配置需要生成Ibatis 配置的表;

7.  “右键”选择“ ”完成操作;

 

完整示例配置文件如下:

< ibatorConfiguration >

< classPathEntry   location = "E:/workspace/antx/repository/jdbc/oracle/ojdbc14.jar"   />

< ibatorContext   id = "context1" >

< jdbcConnection   driverClass = "oracle.jdbc.driver.OracleDriver"

connectionURL = "jdbc:oracle:thin:@10.2.224.34:1521:aepdb"   userId = "core"

password = "core"   />

< javaModelGenerator   targetPackage = "com.alisoft.model"

targetProject = "test/src/" >

< property   name = "enableSubPackages"   value = "false"   />

< property   name = "trimStrings"   value = "true"   />

</ javaModelGenerator >

< sqlMapGenerator   targetPackage = "com.alisoft.model.sql"

targetProject = "test/src/" >

< property   name = "enableSubPackages"   value = "false"   />

</ sqlMapGenerator >

< daoGenerator   targetPackage = "com.alisoft.dao"

targetProject = "test/src/"   type = "GENERIC-CI" >

< property   name = "enableSubPackages"   value = "false"   />

</ daoGenerator >

< table   tableName = "ADMIN_USER"   domainObjectName = "Admin" / >

</ ibatorContext >

</ ibatorConfiguration >

补充说明:

1.  如果指定的 targetPackage 不存在,Ibator 会帮我们自动生成;

2.  根据官方文档描述," daoGenerator  "是一个可选配置,但是实际情况是不配置该选项 xml 验证能通过,但是会报一个类似空指针的错误;

3.  以上描述均在本人机器上测试通过;

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值