Search code examples
javaspringspring-bootcsvspring-batch

Not getting data from .csv file to mysql database using spring boot batch


why the write count is 0

Step already complete or not restartable, so no action to execute:

StepExecution: id=27, version=103, name=step1, status=COMPLETED, exitStatus=COMPLETED, readCount=1000, filterCount=1000, writeCount=0 readSkipCount=0, writeSkipCount=0, processSkipCount=0, commitCount=101, rollbackCount=0, exitDescription=

Solution

  • In the log provided we can see readCount=1000, filterCount=1000, writeCount=0. It means that all items read from the CSV file have been rejected in the ItemProcessor. Filtered out due to some condition inside the class and returned as null. It was not due to an exception because readSkipCount=0.

    Inspect or debug the code of PersonItemProcessor to understand the reason of this behavior.

    Please note: your step is configured to run only once until it get the state COMPLETED. In case you have modified the code and want the step to run again you can set a property AllowStartIfComplete. Like this:

    return stepBuilderFactory.get("step1")
                .<DataEntity, DataEntity> chunk(5)
                .allowStartIfComplete(true)
                .reader(reader())
                .processor(processor())
                .writer(writer())
                .build();