开发者社区> 问答> 正文

请教SpringBatch的事务问题?报错

运行时报错 

java.lang.IllegalStateException: Existing transaction detected in JobRepository. Please fix this and try again (e.g. remove @Transactional annotations from client).


请问下这个问题如何解决?调用JobLanch.run方法的地方是在Spring的service里,单独开启事务和共享事务都不行,求教各位~

展开
收起
爱吃鱼的程序员 2020-06-14 21:49:51 1015 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    Use  AbstractJobRepositoryFactoryBean.ValidateTransactionState,butusecarefully(Warning:Dragonsahead).

    Touseanothertransactionyoucaninjectacustom SimpleJobLauncher.executor withmethod Executor.run markedas@Transactional()(orcreateacustom JobLauncher anddothesametrickonmethod run).

    来自 http://stackoverflow.com/questions/18125394/start-a-spring-batch-job-when-already-within-a-transaction


    2020-06-14 21:50:07
    赞同 展开评论 打赏
问答分类:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载