spring 的事务失效
进来在研究spring的事务,可是在配置的时候采用tx标签的方法可以实现事务的回滚,然后又用了spring声明,代理的方法
xml配置如下:
<!-- 声明式事务 -->
<!-- 事务代理拦截器的配置 -->
<bean id="transactionInterceptor"
class="org.springframework.transaction.interceptor.TransactionInterceptor">
<!-- 配置事务管理器 -->
<property name="transactionManager" ref="transactionManager" />
<!-- 配置事务属性 -->
<property name="transactionAttributes">
<props>
<prop key="insert*">PROPAGATION_REQUIRED,-Exception</prop>
<prop key="update*">PROPAGATION_REQUIRED,-Exception</prop>
<prop key="delete*">PROPAGATION_REQUIRED,-Exception</prop>
<prop key="*">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>
<!-- 配置哪种方法 这一段没有也有错误-->
<bean id="trasactionMethodPointcutAdvisor" class="org.springframework.aop.support.NameMatchMethodPointcutAdvisor">
<property name="mappedNames">
<list>
<value>*</value> <!-- 所有方法 -->
</list>
</property>
<property name="advice">
<ref local="transactionInterceptor" />
</property>
</bean>
<!-- 自动代理 -->
<bean class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
<property name="beanNames">
<list>
<value>*Service</value>
</list>
</property>
<property name="interceptorNames">
<list>
<value>transactionInterceptor</value>
</list>
</property>
</bean>
然后在service 抛出异常,数据还是插入到表中一条。数据库用的mysql 表的类型是InnoDB
求解,各位大神帮忙!谢谢啦!