<!-- 配置事务管理器 --> <bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="dataSource"/> </bean>
<!-- 配置事务管理advice --> <tx:advice id="txAdvice" transaction-manager="txManager"> <tx:attributes> <tx:method name="get*" read-only="true" /> <tx:method name="find*" read-only="true" /> <tx:method name="select*" read-only="true"/> <tx:method name="query*" read-only="true"/> <tx:method name="search*" read-only="true"/> <tx:method name="count*" read-only="true" /> <tx:method name="*" propagation="SUPPORTS" rollback-for="java.lang.Exception"/> </tx:attributes> </tx:advice>
<!-- 配置切入点切面 --> <aop:config> <aop:pointcut id="txPointcut" expression="(execution(* com.avcon.*.*.service..*.*(..))) or (execution(* com.avcon.*.*.controller..*.*(..)))" /> <aop:advisor pointcut-ref="txPointcut" advice-ref="txAdvice" /> <!-- 增强代码 --> <aop:aspect order="-2147483648" ref="dynamicDataSourceAop"> <aop:around pointcut-ref="txPointcut" method="doAroundMethod"/> <!-- <aop:after-returning method=""/> <aop:before method=""/> <aop:after-throwing method=""/> <aop:after method=""/> --> </aop:aspect> </aop:config>