spring和ibatis集成application-system.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<!--1. 配置数据源 -->
<bean id="myDataSource" ref="myDataSource"/>
</bean>
<!--3. 配置DAO -->
<bean id="MessageDao" ref="myDataSource"/>
<property name="sqlMapClient" ref="mySqlMapClient"/>
</bean>
<!--4. 配置服务类 -->
<bean id="MessageServiceImpl"
ref="MessageDao" />
</bean>
<!--5. 配置事务管理器TransactionManager -->
<bean id="myTransactionManager"
ref="myDataSource"/>
</bean>
<!--6. 配置事务代理 -->
<bean id="abstrac"
ref="myTransactionManager"/>
<property name="transactionAttributes">
<props>
<!--把CustomBuyException减去.说明它即使不是runtimeException,也会rollback-->
<!--把CustomBuyException加上.说明它即使是runtimeException,也不会rollback-->
<prop key="*">-DataAccessException</prop>
</props>
</property>
</bean>
<!-- 继承abstrac 方便多个service来映射 -->
<bean id="messageService" parent="abstrac">
<property name="target" ref="MessageServiceImpl"/>
</bean>
</beans>