1、spring配置文件中增加以下代码
<bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
<property name="configLocation" value="classpath:conf/ibatis/sqlmap-config.xml"/>
<property name="dataSource" ref="dataSource" />
</bean>
<bean id="xxxxx" class="xxxxxx">
<property name="sqlMapClient" ref="sqlMapClient"/>
</bean>
2、ibatis配置文件sqlmap-config.xml中引入具体的ibatis配置文件即可
<sqlMap resource="conf/ibatis/ibatis.xxx.xml" />
3、所有dao类都继承com.ibatis.sqlmap.client.SqlMapClient
<bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
<property name="configLocation" value="classpath:conf/ibatis/sqlmap-config.xml"/>
<property name="dataSource" ref="dataSource" />
</bean>
<bean id="xxxxx" class="xxxxxx">
<property name="sqlMapClient" ref="sqlMapClient"/>
</bean>
2、ibatis配置文件sqlmap-config.xml中引入具体的ibatis配置文件即可
<sqlMap resource="conf/ibatis/ibatis.xxx.xml" />
3、所有dao类都继承com.ibatis.sqlmap.client.SqlMapClient
本文介绍如何在Spring框架中整合iBatis,通过配置Spring和iBatis的相关XML文件实现DAO层的数据访问操作。
964

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



