读书人

spring集成iBATIS宣言式事务管理配置及

发布时间: 2012-10-09 10:21:45 作者: rapoo

spring集成iBATIS声明式事务管理配置及测试
applicationContext.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: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/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">          <!-- 配置iBATIS声明式事务管理 -->               <bean id="dataSource" destroy-method="close">     <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"/>     <property name="url" value="jdbc:oracle:thin:@192.168.0.100:1521:orcl"/>     <property name="username" value="scott"/>     <property name="password" value="tiger"/>     </bean>          <bean id="txManager" ref="dataSource"/>     </bean>          <tx:advice id="txAdvice" transaction-manager="txManager">     <tx:attributes>     <tx:method name="add*" propagation="REQUIRED"/>     <tx:method name="del*" propagation="REQUIRED"/>     <tx:method name="update*" propagation="REQUIRED"/>     <tx:method name="get*" read-only="true"/>     </tx:attributes>     </tx:advice>          <aop:config>     <aop:pointcut id="allManagerMethod" expression="execution(public * com.sample.service.*.*(..))"/>     <aop:advisor pointcut-ref="allManagerMethod" advice-ref="txAdvice"/>     </aop:config>           <bean id="sqlMapClient" ref="dataSource" />     </bean>          <!-- 配置用户定义Bean -->     <bean id="userService" ref="userDao"/>     <property name="logDao" ref="logDao"/>     </bean>          <bean id="userDao" ref="sqlMapClient"/>     </bean>          <bean id="logDao" ref="sqlMapClient"/>     </bean>     </beans>

读书人网 >软件架构设计

热点推荐