<bean id="txManger" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"/>
</bean>
<!-- 定义声明式事物规则-->
<tx:advice id="txAdvice" transaction-manager="txManger">
<tx:attributes>
<tx:method name="find" propagation="SUPPORTS"/>
<tx:method name="insert" propagation="REQUIRED"/>
<tx:method name="update" propagation="REQUIRED"/>
<tx:method name="delete" propagation="REQUIRED"/>
</tx:attributes>
</tx:advice>
<aop:config>
<!-- 定义切面-->
<aop:pointcut id="service" expression="execution(* com.*.*(..))"/>
<!-- 事物增强切入点组合-->
<aop:advisor advice-ref="txAdvice" pointcut-ref="service"/>
</aop:config>
spring mvc 声明式事物定义
最新推荐文章于 2022-04-04 12:00:00 发布