[Spring Batch] Error : java.lang.IllegalStateException: If a skip limit is provided then skippable exceptions must also be specified

If you got error like below.

What should do with is in a message.

If you specify skip-limit in chunk, you also need to specify which exception you want skip.

Below example would be skip when exception has occurred. And skipped only exception which extends java.lang.Exception.

[Spring Batch] (For forgot) What ItemReader should do

ItemReader get batch target object.

T read() method called until it returns null.
Therefore Spring batch would do something like below.

  1. Read record(s) by ItemReader.
  2. Do something at ItemProcessor.
  3. Write results at ItemWriter. When writing results, set flag or delete source data so that ItemReader would not to read same data again.

Or you can do like below. But you should be aware of exception handling.

  1. Read all target records and cached them at ItemReader.Then ItemReader returns one(or some) record(s).
  2. Do something at ItemProcessor.
  3. Write something at ItemWriter.

In this case, ItemReader keep records and current position.
To do this, you must define the ItemReader with scope=”step” in Bean Configuration.
scope=”step” means instance lifecycle is Step.
So you can keep current position as class member and it keeps until ItemReader returns null.