注入
@Autowired private DataSourceTransactionManager transactionManager;
TransactionStatus transactionStatus = transactionManager.getTransaction(new DefaultTransactionDefinition()); try{ //dosomething
transactionManager.commit(transactionStatus);
}catch(Exception ex){
transactionManager.rollback(transactionStatus);
}