我有一个春季启动应用程序和使用骆驼与它,我读了一个文件,然后我尝试插入我的数据库,一切都运行良好唯一的问题是,我尝试使用@transactional
或transactionTemplate
使回滚时发生错误,但它不会使回滚,如何管理在春季启动交易
随着@transactional
我添加到我的SpringBootApplication和@EnableTransactionManagement(proxyTargetClass=true)
在我的课我添加@Transactional(rollbackFor = Exception.class)
这些都是我的类:
@SpringBootApplication
@EnableDiscoveryClient
@EnableTransactionManagement(proxyTargetClass=true)
public class MsArchivo510Application {
public static void main(String[] args) {
SpringApplication.run(MsArchivo510Application.class, args);
}
}
@Service
public class ArchivoBS implements Processor{
@Transactional(rollbackFor = Exception.class)
@Override
public void process(Exchange exchange) throws Exception {
//Here I execute stored procedure and one of them fail
}
}
随着transactioTemplate我的课结束这样的:
@Service
public class ArchivoBS implements Processor{
@Override
public void process(Exchange exchange) throws Exception {
transactionTemplate.execute(new TransactionCallbackWithoutResult() {
@Override
protected void doInTransactionWithoutResult(TransactionStatus status) {
try {
//Here I execute stored procedure and one of them fail
} catch (Exception e) {
e.printStackTrace();
status.setRollbackOnly();
}
}
});
}
}
难道我失去了一些东西?有人可以帮助我这个问题?提前
感谢
所以你的意思是有从存储过程的调用分离处理器? –
我尝试你提到的但它不起作用 –