spring Existing transaction found for transaction marked with propagation 'never' 解决
先在申明事务中配置了所有的事务
<!--配置事物传播策略,以及隔离级别--> <tx:advice id="txAdvice" transaction-manager="jdbcTransactionManager"> <tx:attributes> <!-- 注入事务策略 --> <tx:method name="delet*" propagation="REQUIRED" isolation="READ_COMMITTED" rollback-for="Exception"/> <tx:method name="updat*" propagation="REQUIRED" isolation="READ_COMMITTED" rollback-for="Exception"/> <tx:method name="delet*" propagation="REQUIRED" isolation="READ_COMMITTED" rollback-for="Exception"/> <tx:method name="inser*" propagation="REQUIRED" isolation="READ_COMMITTED" rollback-for="Exception"/> <!-- <tx:method name="*" propagation="REQUIRED" isolation="READ_COMMITTED"/> --> </tx:attributes> </tx:advice>
因为配置了
<tx:method name="*" propagation="REQUIRED" isolation="READ_COMMITTED"/> 所有所有的事务都是REQUIRED
service 实现层配置了注解方式
@Override @Transactional(propagation = Propagation.NEVER,rollbackFor = Exception.class) public void never() { dao.queryInfo(); }
传播级别是NEVER 报出:
HTTP Status 500 - Request processing failed; nested exception is org.springframework.transaction.IllegalTransactionStateException: Existing transaction found for transaction marked with propagation 'never'
解决:将配置文件的
<tx:method name="*" propagation="REQUIRED" isolation="READ_COMMITTED"/>
删除掉