精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2011-06-28
源地址:
下载ibator插件地址:
现在我们着手来写一个ibatis的简单例子.
ojdbc14.jar ibatis-common.jar ibatis-dao.jar ibatis-sqlmap.jar
3.由于你安装
了ibator插件,那么你在你的工程某个目录下单击右键-->new-->other里将会看到
Apache iBatis ibator configuration File
点击以后要求你输入文件名(这个就是 ibator的 配置 文件):
Location: test/src File name: ibatorConfig.xml
填入配置
文件名称,可以随便设置配置
文件名字。一般为“ibatorConfig.xml”,点确定后就创建好了一个ibator配置
文件的模板。
<?
xml version
=
"
1.0
"
encoding
=
"
UTF-8
"
?>
<! DOCTYPE ibatorConfiguration PUBLIC " -//Apache Software Foundation//DTD Apache iBATIS Ibator Configuration 1.0//EN " " http: //ibatis.apache.org/dtd/ibator-config_1_0.dtd " > < ibatorConfiguration > < ibatorContext id = " context1 " > < jdbcConnection driverClass = " ??? " connectionURL = " ??? " userId = " ??? " password = " ??? " /> < javaModelGenerator targetPackage = " ??? " targetProject = " ??? " /> < sqlMapGenerator targetPackage = " ??? " targetProject = " ??? " /> < daoGenerator targetPackage = " ??? " targetProject = " ??? " type = " GENERIC-CI " /> < table schema = " ??? " tableName = " ??? " > < columnOverride column = " ??? " property = " ??? " /> </ table > </ ibatorContext > </ ibatorConfiguration >
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE ibatorConfiguration PUBLIC "-//Apache Software Foundation//DTD Apache iBATIS Ibator Configuration 1.0//EN" "http://ibatis.apache.org/dtd/ibator-config_1_0.dtd" > <ibatorConfiguration> <!-- jdbc的连接jar包路径 --> <classPathEntry location="E:\Workspace\test\WebRoot\WEB-INF\lib\ojdbc14.jar" /> <ibatorContext id="context1"> <!--jdbc的连接jar包路径 --> <!-- driverClass驱动类地址 --> <!-- connectionURL连接数据库的URL地址 --> <!-- userId连接数据库账号 --> <!-- password连接数据库密码 --> <jdbcConnection driverClass="oracle.jdbc.driver.OracleDriver" connectionURL="jdbc:oracle:thin:@localhost:1521:test" userId="test" password="test" > </jdbcConnection> <!-- jdbc创建表的Pojo类 --> <!-- targetPackage创建包名--> <!-- targetProject指定项目名 --> <javaModelGenerator targetPackage="com.mode" targetProject="test" /> <!-- jdbc创建表与Pojo类的映射xml --> <!-- targetPackage创建包名--> <!-- targetProject指定项目名--> <sqlMapGenerator targetPackage="com.xml" targetProject="test" /> <!-- jdbc创建表的Dao增删改查执行语句 --> <!-- targetPackage创建包名--> <!-- targetProject指定项目名 --> <daoGenerator targetPackage="com.dao" targetProject="test" type="IBATIS" /> <!-- 本配置文件所要映射的表 --> <!-- domainObjectName是此表映射成对象的名字 --> <table tableName="T_TEST" domainObjectName="test"> </table> </ibatorContext> </ibatorConfiguration>
5.之后我们只需要在这个配置 文件上点击右键-->点击Generate ibatis artifacts,这样就应该能生成对应的package 和 类了
6.如果出现错误使用一下方式查看错误日志
运行cmd用来查询ibatorConfig.xml中出现的错误日志 java -jar d:\ibator.jar -configfile E:\Workspace\test\src\ibatorConfig.xml -overwrite >>c:\log.log 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |
浏览 2507 次