<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="basicDataSource"></property>
</bean>
<!-- <tx:annotation-driven transaction-manager="transactionManager"/> -->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="update" rollback-for="Exception" />
</tx:attributes>
</tx:advice>
<aop:config>
<aop:pointcut expression="execution(* cn.tianqi.demo.service..*.*(..))"
id="servicePointCut" />
<aop:advisor advice-ref="txAdvice" pointcut-ref="servicePointCut" />
</aop:config>
@Transactional
public int update(int id,int change){
int t=airQualityIndexMapper.update(id,change);
if(0==0){
throw new RuntimeException("0");
}
return t;
}