Reputation: 139
I am trying to add a new step to my Spring Batch job that will create an XLS file. I have a reader that puts the output to a bean called CLUCReportDTO. I am working on the blueprint of the itemWriter to create the CSV file. Here is the code
Inside the A8SPACH2 class
@Autowired
private ACH2WriteProcessor clucWriter;
public Step jobStep020() {
return stepBuilderFactory.get(JOB.ACH2_BATCH_LOAD.getProfileName() +
".js020")
.listener(promotionListener)
.<CLUCReportDTO, String> chunk(100)
.reader(lockboxWirePostService.getUnappliedJes())
.writer(clucWriter)
.listener(listener)
.build();
}
Inside the ACH2WriteProcessor class
public class ACH2WriteProcessor implements ItemWriter<CLUCReportDTO>{
@Override
public void write(List<? extends CLUCReportDTO> items) throws Exception
{
}
}
I am getting the following error in A8SPACH2: Cannot be converted to ItemWriter< ? Super String> . What am I missing in the setup of either A8SPACH2 or ACH2WriteProcessor that is causing this error.
Thanks
Upvotes: 0
Views: 2792
Reputation: 31745
According to your configuration (.<CLUCReportDTO, String> chunk(100)
), the item writer is expected to write items of type String
, but you are declaring it to write items of type CLUCReportDTO
(public class ACH2WriteProcessor implements ItemWriter<CLUCReportDTO>
).
Your item writer should be declared like this:
public class ACH2WriteProcessor implements ItemWriter<String>{
@Override
public void write(List<? extends String> items) throws Exception {
}
}
Upvotes: 1