<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="dataSource" /> </bean> <bean id="transactionTemplate" class="org.springframework.transaction.support.TransactionTemplate"> <constructor-arg ref="transactionManager" /> </bean> <!-- 事务拦截器 --> <tx:advice id="txAdvice" transaction-manager="transactionManager"> <tx:attributes> <!-- methods starting tx, just as 'save', 'update' or 'remove' use the default transaction settings --> <tx:method name="save*" /> <tx:method name="update*" /> <tx:method name="remove*" /> <tx:method name="delete*" /> <!-- other methods are set to read only --> <tx:method name="*" read-only="true" /> </tx:attributes> </tx:advice> <!-- 事务拦截包配置 myproject..*Service.*(..),对package gov.UserService 的方法都拦截 --> <aop:config proxy-target-class="true"> <aop:advisor pointcut="execution(* gov..*Service.*(..))" advice-ref="txAdvice" /> </aop:config> <aop:config proxy-target-class="true"> <aop:advisor pointcut="execution(* gov..*Manager.*(..))" advice-ref="txAdvice" /> </aop:config>