开发者社区 问答 正文

请教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 1226 分享 版权
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
    赞同 展开评论
问答分类:
问答地址: