Loading
0

Spring事务编程

编程式事务:

    @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);
        }
  

最后编辑于:2024/5/23作者: joycode

我不入地狱,谁入地狱?

评论已关闭