编程式事务:
@Bean public PlatformTransactionManager transactionManager(DataSource dataSource) { return new DataSourceTransactionManager(dataSource); }
使用:
@Autoware private PlatformTransactionManager platformTransactionManager; TransactionStatus transactionStatus = platformTransactionManager.getTransaction(new DefaultTransactionDefinition()); try { platformTransactionManager.commit(transactionStatus); } catch (Exception e) { platformTransactionManager.rollback(transactionStatus); }
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END