先在申明事務中配置了所有的事務
<!--配置事物傳播策略,以及隔離級別--> <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"/>
刪除掉