简体   繁体   English

我们能否在通过Spring Boot应用程序运行的spring批处理中的两个作业之间传递参数

[英]Can we pass parameters between two jobs in spring batch which run via spring boot application

Is there way to pass parameters that are set in first job to second spring job. 有没有办法将在第一工作中设置的参数传递给第二弹簧工作。 I am not talking about steps here, I know with executionCOntext I can pass between two steps , how about two jobs in spring batch. 我在这里不是在讨论步骤,我知道通过执行COntext我可以在两个步骤之间传递,春季批处理中的两个作业怎么样。

Thanks 谢谢

You could pass a reference to the JobRepository to your Job class (either in the constructor of via @Autowired ). 您可以将对JobRepository的引用传递给Job类(通过@Autowired的构造函数)。

It´sa weird setup, but with that you could access details about other Jobs parameters and execution. 这是一个奇怪的设置,但是通过它您可以访问有关其他Jobs参数和执行的详细信息。 Bear in mind that you might encounter race conditions if the Jobs you are checking are still running. 请记住,如果您要检查的作业仍在运行,则可能会遇到竞赛条件。

See the docs about the JobRepository here 此处查看有关JobRepository的文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM