- 浏览: 235529 次
- 性别:
- 来自: 沈阳
文章分类
最新评论
-
Araxis:
也遇到了楼主的问题,我用的sockjs.0.3.4,升级版本到 ...
Websocket出现的错误 -
love_jun1314:
怎么进行转换成功并没有看到a.flv文件呢? 你把commen ...
java调用ffmpeg执行视频转换 -
枫林top:
不错,挺好的
看老外程序员如何向妻子解释设计模式 -
likj_sh:
太感谢了 ,困惑了好久
Struts2 + Spring + Hibernate + DWR 项目布署笔记 -
dhl004:
...
web.xml 通过contextConfigLocation配置spring 的方式
最近做一个项目要用到ibatis、struts2、spring框架,以前看到过ibatis生成工具。想在项目中使用,下了官方的文档,里面有几种方法生成方法:buider.xml,java Class等,研究了一下,花了很多时间,现在觉得还是用插件好一些,现成的东西不用,要用什么命令行,真傻!咱做的是技术应用,不是研发,能最快用技术解决需要才是重点。下面总结一下用Eclipse Plugin生成sqlmap.xml,javabean,dao,daoimp等的方法: 说明: 它提供两种方式:一种是Eclipse插件,一种是独立运行。 目前针对Eclipse的版本有两个版本, 1.2.1能运行在: · Eclipse 3.4.1 or higher · JDK 5.0 or Higher · 它的Eclipse插件URL下载地址为:http://ibatis.apache.org/tools/ibator 1.1.0运行在: · Eclipse 3.2 or higher · JDK 1.4 or Higher · 它的Eclipse插件URL下载地址为:http://ibatis.apache.org/tools/abator 注意:版本问题,笔者开始用的是myEclipse6.0.1,是eclipse 3.3.1平台,装了1.2.1怎么也不能用,调查才发现,不要因为版本而影响作用。 范例: 点击后就会新建一个文件:abatorConfig.xml。 以下是1.1.0的写法,供大家参照: <?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.microsoft.jdbc.sqlserver.SQLServerDriver" connectionURL="jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=cmspro" userId="cmspro" password="cmspro" > <classPathEntry location="D:/POM/project/msbase.jar" /> <classPathEntry location="D:/POM/project/mssqlserver.jar"/> <classPathEntry location="D:/POM/project/msutil.jar" /> </jdbcConnection> <javaModelGenerator targetPackage="com.ucap.account.model" targetProject="account-service-impl" /> <sqlMapGenerator targetPackage="resources.sqlmaps" targetProject="account-service-impl" /> <daoGenerator targetPackage="com.ucap.account.dao" targetProject="account-service-impl" type="GENERIC-CI" /> <table tableName="cmspro_channel_privilege" domainObjectName="ChannelPrivilege"/> </abatorContext> </abatorConfiguration> 这里<table>标签中的domainObjectName,是用来重新命名类名。 以下是1.2.1的写法,供大家参照: <?xml version="1.0" encoding="UTF-8"?> 以上书写好xml后,请鼠标右键点击该xml文件生成Artifacts
这里使用的是ibator作为ibatisEclipse插件,ibator的主页是:http://ibatis.apache.org/ibator.html
新建一个工程,然后在该工程下新建文件,截图如下:(如果这里没有请到other..中找,截图如右:)
<!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>
<!--
url 指定属性文件绝对路径。注意与指定数据库jdbc驱动jar包路径的区别哈。
可以使用${property}的格式引用属性文件中的属性值。
<properties url="D:/WorkSpace/SSIStudy/ibator-config.properties"/>
-->
<!--
classPathEntry 指定数据库jdbc驱动jar包的绝对路径。 可为为空
The full path name of a JAR/ZIP file to add to the classpath, or a directory to add to the classpath
-->
<classPathEntry location="D:/WorkSpace/SSIStudy/WebRoot/WEB-INF/lib" />
<!--
id 这个id可以在使用命令行运行Abator时指定,以单独处理某一个ibatorContext
targetRuntime Ibatis2Java5 生成适合JDK5.0的类,另一个选项是 Ibatis2Java2,生成适合Java2的类。
-->
<ibatorContext id="SSIStudy" targetRuntime="Ibatis2Java2">
<!--
ibatorPlugin 继承自IbatorPluginAdapter,包名必须是 org.apache.ibatis.ibator.plugins,具体实现可以参考官方文档
必须有替换和被替换字符属性。 可以没有
-->
<!--
<ibatorPlugin type="org.apache.ibatis.ibator.plugins.RenameExampleClassPlugin">
<property name="searchString" value="Example$" />
<property name="replaceString" value="Criteria" />
</ibatorPlugin>
driverClass 数据库驱动类 这里连接sqlserver2000
connectionURL 数据库连接地址
userId 用户
password 密码
还可以使用以下格式添加数据库的其他连接属性
<property name="" value=""/>
-->
<jdbcConnection driverClass="com.microsoft.jdbc.sqlserver.SQLServerDriver" connectionURL="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=demo" userId="sa" password="sa" >
</jdbcConnection>
<javaTypeResolver >
<!--
默认false,把JDBC DECIMAL 和 NUMERIC 类型解析为 Integer
true,把JDBC DECIMAL 和 NUMERIC 类型解析为java.math.BigDecimal
-->
<property name="forceBigDecimals" value="false" />
</javaTypeResolver>
<!-- //When running outside of an IDE environment like Eclipse, Ibator interprets the targetProject and targetPackage attributes in all XML configurations as follows
targetProject 生成的Java Bean放置在哪个项目的哪个目录下
targetPackage 生成的Java Bean的包名
一个有用的属性
从数据库返回的值被清理前后的空格
<property name="trimStrings" value="true" />
是否在包名后加上scheme名称
<property name="enableSubPackages" value="false" />
-->
<javaModelGenerator targetPackage="cn.per.jiabeis.model" targetProject="D:/WorkSpace/SSIStudy/src">
<property name="enableSubPackages" value="true" />
<property name="trimStrings" value="true" />
</javaModelGenerator>
<!--
targetProject 生成的 SqlMap.xml 文件放置在哪个项目的哪个目录下
targetPackage 生成的 SqlMap.xml 文件的包名
<property name="enableSubPackages" value="false" />
是否在包名后加上scheme名称
-->
<sqlMapGenerator targetPackage="cn.per.jiabeis.model.config" targetProject="D:/WorkSpace/SSIStudy/src">
<property name="enableSubPackages" value="true" />
</sqlMapGenerator>
<!--
targetProject 生成的 dao类文件放置在哪个项目的哪个目录下
targetPackage 生成的 dao类文件的包名
<property name="enableSubPackages" value="false" />
是否在包名后加上scheme名称
type 生成dao文件的类型,可选择IBATIS、SPRING、GENERIC-CI、GENERIC-SI。默认使用GENERIC-CI
dao类在构造器中获取 SqlMapClient。
-->
<daoGenerator targetPackage="cn.per.jiabeis.dao" targetProject="D:/WorkSpace/SSIStudy/src" type="IBATIS">
<property name="enableSubPackages" value="true" />
</daoGenerator>
<!--
tableName 数据库表明,据说可以包含SQL通配符%和_。
domainObjectName 数据库表对应的数据对象名称,默认使用表名作为对象名称。
-->
<table tableName="student" domainObjectName="Student">
<!--
对象的属性名是否使用字段名称,默认为true
-->
<property name="stuname" value="stuname"/>
<!--
column 自增长或使用sequence生成的字段名
sqlStatement 生成字段的sql片段或其简称(参考官方文档)
identity true表示后生成,false表示预生成
例如:
postgresql:<generatedKey
column="lid"
sqlStatement="select nextval('tb000000producttype_lid_seq')"
identity="false" />
sqlserver:<generatedKey
column="lid"
sqlStatement="SqlServer"
identity="true" />
oracle:<generatedKey
column="lid"
sqlStatement="select tb000000producttype_lid_seq.nextval from dual"
identity="false" />
MySql:<generatedKey
column="lid"
sqlStatement="MySql"
identity="false" />
-->
<generatedKey column="stuid" sqlStatement="SqlServer" identity="true"/>
<!--
数据库字段名称到对象属性名称的影射关系。就是一个替换处理。
-->
<columnRenamingRule searchString="^CUST_" replaceString="" />
<!--
column 字段名
property 字段对应的属性名。(默认使用字段名的)
javaType 对应的Java类型
jdbcType 对应的jdbc类型
这里的设置覆写javaTypeResolver中的指定
-->
<columnOverride column="DATE_FIELD" property="startDate" />
<!--
column 需要忽略的数据库字段
-->
<ignoreColumn column="FRED" />
</table>
<table tableName="teacher"/>
<table tableName="course"/>
<table tableName="stu_course"/>
</ibatorContext>
</ibatorConfiguration>
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/jiabeis/archive/2010/05/04/5554688.aspx
发表评论
-
jstl fmt:formatdate转载
2015-07-21 15:25 536<%@ page language=&qu ... -
JSR-356 WebSocket API规范中文版
2014-10-21 17:21 840转:http://jinnianshilongnian.it ... -
EL表达式大全
2014-10-10 14:29 6251.uri="http://java.sun.c ... -
Windows下Github使用方法
2013-01-31 10:35 927Windows下Github使用方法 ... -
StringUtils详细介绍
2013-01-23 23:40 884StringUtils详细介绍 publi ... -
一些常用的HTTP头
2013-01-23 18:08 824以下附录在编程常要获取的,包括获取一些常用的HTTP头: ... -
Ognl方法使用(利用表达式语言获取数据)
2013-01-05 23:40 2785WebWork的EL-对象图导航语言(Object Graph ... -
Struts2 中 OGNL 如何更简单的访问静态变量和静态方法
2013-01-05 22:37 1103在 struts2 标签中是使用 OGNL 来访问对象属性或方 ... -
web.xml 通过contextConfigLocation配置spring 的方式
2011-09-21 11:21 2178SSI框架配置文件路径问题:struts2的 1个+N个 ... -
正则表达式收藏(四)之MySQL的正则
2011-03-14 12:58 1096正则表达式(regex)是定义复杂查询的一个强有力的工具。 这 ... -
J2EE工程源代码编写规则(命名规范)
2010-12-03 16:08 2337源代码编写规则目的:能够在编码过程中出现规则化,为以后的程序D ... -
EL表达式函数!
2010-01-22 12:29 1660首先必须在JSP中声明这个标签库:<%@ taglib ... -
eclipse svn插件不能正常显示的解决办法
2009-10-20 09:44 907eclipse 中使用 svn 插件,原本正常,未作任何更改 ... -
Oracle 10g 控制台服务起不来
2009-10-06 13:38 2384C:\Documents and Settings\benbe ... -
Spring2文件上传实例
2009-09-25 17:43 1137web.xml文件内容: <?xml version= ... -
struts2+spring+hibernate 上传文件
2009-09-25 10:10 1955前段时间,我用struts2.1.6、spring2.5、hi ... -
struts.properties文件
2009-06-18 11:12 1049这个文件是struts2框架的全局属性文件,也是自动加载的文件 ... -
Spring框架的事务管理及应用
2009-06-18 10:45 836Spring框架简介 Spring框架 ... -
spring+hibernate中clob、blob字段的处理方法
2009-06-18 10:34 1836今天在开发项目的时候遇到CLOB字段的问题,和平时的Strin ... -
oracle10g中EM的有关问题解决
2009-06-10 11:33 2158Oracle 10g中的EM采用Web的 ...
相关推荐
开源ibator什么xml和pojo的时候,经常会带一些讨厌的注释还有一些没用的ibatorgenerator等的,我改了它的源代码,弄了个干净的ibator
NULL 博文链接:https://dr-yanglong.iteye.com/blog/1936559
Ibator is a code generator for iBATIS. Ibator will introspect a database table (or many tables) and will generate iBATIS artifacts that can be used to access the table(s). This abates some of the ...
NULL 博文链接:https://xiao9.iteye.com/blog/954159
ibator-huoniao通过它你可以通过配置少量参数,通过一键生成dao层的全部文件,能够应付对dao层的所有操作 产物包括: 1. pojo文件 2. dao接口类 3. dao接口实现类文件 4. ibatis sql map文件 5. 数据库查询时...
iBATIS课件 iBATIS简介 搭建环境 配置文件 读取配置 基本的CRUD操作 模糊查询 iBATIS代码生成工具iBATOR 优缺点 选择Hibernate还是iBATIS
ibatis 配置文件自动生成工具
ibatis3的自动代码生成工具ibator参考文档,快速开发dao的好东西。
ibatis ibator eclipes插件 代码生成器 代码自动生成工具 下载后将features和plugins两个文件夹下的文件拷贝到eclipes安装路径下对应的features和plugins两个文件夹下即可
这是一个用iBator生成iBatis有关代码的例子。 特别说明: Eclipse应该是3.4.1以上版本, 并且安装了iBator插件。否则可用iBator的命令行版本或ant工具。 测试用数据是: CREATE TABLE PERSON( id INTEGER NOT NULL,...
ibator_doc.chm iBatis的自动生成工具!
用户ibatis自动成才代码的一种工具,减少开发人员的工作量。
ibatis代码自动生成工具Eclipse插件,已进行优化处理,不生成注释和精简dao方法,亲测可用
GameServer一个服务器处理框架,包括 协议处理,消息处理,持久层数据...来对服务器的管理使用ibatis做持久层采用ibator做自动代码生成工具,减少开发中对数据库编码的工作量使用mina2.0.9做网络通信提供网络通信的性