使用配置:
<bean id=" txManager " class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref= "dataSource" /> </bean> <aop:config> <aop:pointcut id=" transactionPointcut " expression=" execution(* cn.itcast.service..*.*(..)) "/> <aop:advisor advice-ref=" txAdvice " pointcut-ref=" transactionPointcut "/> </aop:config> <tx:advice id=" txAdvice " transaction-manager=" txManager "> <tx:attributes> <!--以 get开始的方法不要事务 --> <tx:method name="get*" read-only="true" propagation="NOT_SUPPORTED"/> <tx:method name="*"/> <!--启用默认事务行为,数据库默认级别 --> </tx:attributes> </tx:advice>
|