我有以下代码
@Bean
public JdbcBatchItemWriter<QuotationDto> writer1() {
return new JdbcBatchItemWriterBuilder<QuotationDto>()
.itemSqlParameterSourceProvider(new BeanPropertyItemSqlParameterSourceProvider<>())
.sql("INSERT INTO ...")
.dataSource(dataSource)
.build();
}
@Bean
public JdbcBatchItemWriter<QuotationDto> writer2() {
return new JdbcBatchItemWriterBuilder<QuotationDto>()
.itemSqlParameterSourceProvider(new BeanPropertyItemSqlParameterSourceProvider<>())
.sql("INSERT INTO ...")
.dataSource(dataSource)
.build();
}
@Bean
public CompositeItemWriter<QuotationDto> compositeItemWriter() {
CompositeItemWriter writer = new CompositeItemWriter();
writer.setDelegates(Arrays.asList(writer1(), writer2()));
return writer;
}
@Bean
public Step step1() {
return stepBuilderFactory.get("step1")
.<QuotationDto, QuotationDto>chunk(5)
.reader(reader())
.processor(processor())
.writer(compositeItemWriter())
.stream(writer1())
.stream(writer2())
.build();
}
我在将 writer1 设置为流时遇到 IntelliJ 错误,因为 id 没有实现 ItemStream。
我究竟做错了什么?有没有人有解决方案?我没有找到太多关于基于 java 的复合编写器配置的信息。