SpringMVC 手动控制事务提交

时间:2025-02-18 17:26:28

<!-- 事务配置 spring 3.0 -->

<beanid="transactionManager class="">

<propertyname="dataSource"ref="dataSource"/>

</bean>

<aop:config>

<aop:pointcutexpression="execution(public * com.*..*Impl.*(..))"id="pointcut"/>

<aop:advisoradvice-ref="txAdvice"pointcut-ref="pointcut"/>

</aop:config>

<tx:adviceid="txAdvice"transaction-manager="transactionManager">

<tx:attributes>

<tx:methodname="query*"propagation="REQUIRED"read-only="true"/>

<tx:methodname="find*"propagation="REQUIRED"read-only="true"/>

<tx:methodname="get*"propagation="REQUIRED"read-only="true"/>

<tx:methodname="save*"propagation="REQUIRED"/>

<tx:methodname="add*"propagation="REQUIRED"/>

<tx:methodname="create*"propagation="REQUIRED"/>

<tx:methodname="delete*"propagation="REQUIRED"/>

<tx:methodname="del*"propagation="REQUIRED"/>

<tx:methodname="remove*"propagation="REQUIRED"/>

<tx:methodname="modify*"propagation="REQUIRED"/>

<tx:methodname="update*"propagation="REQUIRED"/>

<tx:methodname="clear*"propagation="REQUIRED"/>

</tx:attributes>

</tx:advice>