1: 书写sqlmap.xml dtd位置׃com.ibatis.sqlmap.engine.builder.xml.sql-map-2.dtd
xml文件头:
2:书写iBATIS - SqlMapConfig.xml dtd位置׃com.ibatis.sqlmap.engine.builder.xml.sql-map-config-2.dtd
xml文件头:
3: Spring - ApplicationContext.xml 中注册SqlMapClient
完整写法
4: DAO实现类继续org.springframework.orm.ibatis.support.SqlMapClientDaoSupport
在Spring配置文件的相关位置注入SqlMapClient
[color=indigo]转载请注明: [url]http://chrislee.iteye.com/[/url][/color]
xml文件头:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMap
PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN"
"http://ibatis.apache.org/dtd/sql-map-2.dtd">
<sqlMap namespace="">
<typeAlias alias="" type=""/>
<cacheModel type="LRU" id="">
<flushInterval hours="24"/>
<property name="size" value="1000"/>
</cacheModel>
</sqlMap>
2:书写iBATIS - SqlMapConfig.xml dtd位置׃com.ibatis.sqlmap.engine.builder.xml.sql-map-config-2.dtd
xml文件头:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMapConfig
PUBLIC '-//ibatis.apache.org//DTD SQL Map Config 2.0//EN'
'http://ibatis.apache.org/dtd/sql-map-config-2.dtd'>
<sqlMapConfig>
<sqlMap resource="bookstore/vo/Book.xml" />
</sqlMapConfig>
3: Spring - ApplicationContext.xml 中注册SqlMapClient
完整写法
<bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
<property name="configLocation" value="/sqlMappingConfig.xml" />
<property name="dataSource" ref="dataSource" />
</bean><!-- 注意:B/S写法 value=WEB-INF/sqlMappingConfig.xml-->
4: DAO实现类继续org.springframework.orm.ibatis.support.SqlMapClientDaoSupport
在Spring配置文件的相关位置注入SqlMapClient
[color=indigo]转载请注明: [url]http://chrislee.iteye.com/[/url][/color]
本文详细介绍了如何使用iBATIS(MyBatis前身)与Spring框架进行集成。包括了iBATIS所需的XML配置文件的编写方法,如sqlmap.xmldtd和iBATIS-SqlMapConfig.xml的DTD位置及文件头设置;Spring-ApplicationContext.xml中SqlMapClient的注册方式;以及DAO实现类继承org.springframework.orm.ibatis.support.SqlMapClientDaoSupport的方法。
408

被折叠的 条评论
为什么被折叠?



