spring 手动提交事务
作者:互联网
在日常工作中,需要将事务try,TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();导致事务无法正常PROPAGATION_REQUIRES_NEW,所以需要手动提交。
@Resource(name="transactionManager") //项目内配置的事务manager
private DataSourceTransactionManager transactionManager;
DefaultTransactionDefinition transDefinition = new DefaultTransactionDefinition();
//开启新事物 transDefinition.setPropagationBehavior(DefaultTransactionDefinition.PROPAGATION_REQUIRES_NEW);
TransactionStatus transStatus = transactionManager.getTransaction(transDefinition);
transactionManager.commit(transStatus);
标签:事务,提交,spring,手动,transDefinition,transStatus,NEW,DefaultTransactionDefinition,tra 来源: https://blog.csdn.net/qq_43583850/article/details/123631806