Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
出于测试目的,我正在创建一个 URL,用户可以点击该 URL 来手动启动后端的批处理作业。然后,我将一些调试数据回传给用户,以便他们可以在浏览器中看到它。
现在,我实际上只是将一个字符串变量从一个函数传递到下一个函数,将每个函数的结果一直返回给用户。我觉得必须有更好的方法来从每个函数中获取我需要的信息并将它们连接起来。
这一切都在一个spring bean上运行,所以我不想让“调试”变量成为类的属性。
您可以扩展 JobExecutionListenerSupport 并获得
public void afterJob(JobExecution jobExecution) for (StepExecution stepExecution : jobExecution.getStepExecutions())
寻找可用于 jobExecution 和 stepExecution 的方法,您可以打印作业完成的所有内容。