【发布时间】:2020-02-12 17:53:20
【问题描述】:
向 Step 添加多个侦听器会导致编译错误。
private Step myStep(DataSource dataSource) {
return stepBuilderFactory.get("myStep")
.<Record, Record>chunk(100)
.reader(reader)
.processor(processor)
.writer(writer)
.faultTolerant()
.listener(stepListener)
.listener(skipListener)
.build();
}
[ERROR] 找不到符号 [ERROR] 符号:方法 build() [错误]位置:类 org.springframework.batch.core.step.builder.StepBuilderHelper
如果我删除了其中一个侦听器,代码就会编译。如何将步骤侦听器和跳过侦听器添加到 Spring Batch 中的容错步骤?
使用 Spring Boot 2.1.8-RELEASE 和 Spring Batch 启动器。
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.8.RELEASE</version>
</parent>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-batch</artifactId>
</dependency>
【问题讨论】:
标签: maven spring-boot spring-batch