spring - Spring Batch,在 writer() 中访问 StepExecution
问题描述
我最近提出了这个问题,但我认为我的目标不够明确。
我有一个由读取器、处理器和写入器组成的步骤。
是writer()
一个CompositeItemWriter
,由两个组成JdbcBatchItemWriter
。在其中一个中,我正在写入将包含一row_count
列的控制表。这个值需要来自StepExecution.getReadCount()
.
我是 Spring Batch 的新手,所以我不确定如何添加一个可以将 a 包装StepExecution
到实际编写器本身的侦听器。
感谢您的阅读。
解决方案
您可以使用带@BeforeStep
注释的方法。
在写入第一项之前调用此方法,spring 应该将 StepExecution 传递给它。
@BeforeStep
public void beforeStep(StepExecution stepExecution) { ... }
推荐阅读
- android - Android Studio 显示“未知的 android 属性‘SherlockSpinner’”
- r - 向量内存耗尽/无法在 R 中分配向量大小错误
- angular - 有条件地应用 Angular 6 Compose 验证器
- angular - Angular 文件上传到 API
- javascript - 如何在 sankey 中显示工具提示而不是 sum
- oracle - PL/SQL:在另一个过程中执行过程
- android - 当我使用根名称导航时,如何在颤振中创建全屏对话框?
- python - 将自定义可训练参数乘以隐藏单元
- c# - 使用 DataView 为 DateRange 过滤 GridView 数据
- python-3.x - 如何摆脱 Python 3 中的 group 参数 must be None for now 错误?