Spring集成ibatis失败,有经验者谈谈。。

这几天一直在看spring framework2带的jpetstore的Spring与ibatis的集成,然后自己用spring mvc+ ibatis写了一个小的实验性web程序,诸如datasource, SqlMapClientFactoryBean, SqlMapClient, transactionManager这样的东西全部用spring注入,这个时候遇到一个问题,怎么取 sqlMapClient出来?包括ibaits参考手册的标准答案都是说用:
String resource = "config/sql-map-config.xml";
Reader reader = Resources.getResourceAsReader (resource);
SqlMapClient sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);
这样的方法来取,但是如果是用依赖注入了,为什么还要用reader去取xml文件呢??

这个地方没想明白,求有经验者指导

然后姑且这样配置之,果然报错,表面Exceptions是sqlMapClient.endTransaction()报空,debug后看具体问题好像是取SqlMapClient的sessionScope的时候为空?我不明白这个的具体意思,看源码也没看明白。这个地方也求又经验者指导。

在纠结了两天之后,我放弃了依赖注入,直接在配置文件sqlmapconfig.xml里配置ibatis,然后直接读取,果然ok了,但是这样就没用上spring的注入了,大家能给点意见么?能说说你们平时用spring+ibatis是怎么用的么?

谢谢谢谢

: )
spring 中有一个类叫
org.springframework.orm.ibatis.SqlMapClientFactoryBean
配置如下
<bean id="sqlMapClient"
class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
<property name="configLocation">
<description>
iBATIS SQL Mapping配置文件名,系统要能够在CLASSPATH中找到该文件
</description>
<value>sqlmap-config.xml</value>
</property>
</bean>

而在sqlmap-config.xml中则是存放其它的需要的配置文件资源
<?xml version="1.0" encoding="GB2312"?>
<!DOCTYPE sqlMapConfig PUBLIC "-//iBATIS.com//DTD SQL Map Config 2.0//EN"
"http://www.ibatis.com/dtd/sql-map-config-2.dtd">
<sqlMapConfig>
<settings cacheModelsEnabled="true"
enhancementEnabled="false"
lazyLoadingEnabled="false"
maxRequests="3000"
maxSessions="3000"
maxTransactions="3000"
useStatementNamespaces="false"/>
<sqlMap resource="sqlmap-mapping-mailmanage.xml"/>
</sqlMapConfig>
使用的时候,我们只要继承SqlMapClientDaoSupport
那么.就可以在代码中.
getSqlMapClientTemplate().queryForList(sqlStmID,
param);
啦..
哈哈.临睡觉前还能答个问题.睡了睡了.