After a chat that got deeper into this issue, the real "issue" is that the ItemReader is being created once instead of once per REST call (aka once per execution of the job). To fix this, make the ItemReader step scoped. This will allow you to get a new instance of the reader with each run which also enables the ability to inject the file name base on job parameters.

From a code perspective, change this:

@Bean
public ItemReader<Person> reader() {

to this:

@Bean
@StepScope
public FlatFileItemReader<Person> reader() {

The reason for the return type change is that Spring Batch will automatically register ItemStreams for you. However when using @StepScope we only see the return you define. In this case, ItemReader doesn't extend/implement ItemStream so we don't know you're returning something we should be auto-registering. By returning FlatFileItemReader we can see all the interfaces/etc and can apply the "magic" for you.

Answer from Michael Minella on Stack Overflow
🌐
GitHub
github.com › chrisgleissner › spring-batch-rest
GitHub - chrisgleissner/spring-batch-rest: REST API for Spring Batch using Spring Boot 2.2 · GitHub
Start job execution (synchronous or asynchronous) with optional job property overrides. The job properties can either be obtained via a custom API or via standard Spring Batch job parameters, accessible from step-scoped beans. To integrate the REST API in your Spring Boot project, first ensure you have an entry point to your application such as
Starred by 91 users
Forked by 44 users
Languages   Java 99.9% | Procfile 0.1%
🌐
GitHub
github.com › nicoraynaud › spring-batch-rest-api
GitHub - nicoraynaud/spring-batch-rest-api: Spring Boot library that exposes a REST API to manage Spring batch (start, stop, list, search jobs, job executions and history) · GitHub
Spring Boot library that exposes a REST API to manage Spring batch (start, stop, list, search jobs, job executions and history) - nicoraynaud/spring-batch-rest-api
Starred by 6 users
Forked by 15 users
Languages   Java 99.7% | Shell 0.3%
🌐
GitHub
github.com › officiallysingh › spring-boot-batch-web
GitHub - officiallysingh/spring-boot-batch-web: Spring batch job as Spring Rest service
Spring batch job as Spring Rest service. Contribute to officiallysingh/spring-boot-batch-web development by creating an account on GitHub.
Author   officiallysingh
🌐
Medium
theoneamin.medium.com › launch-spring-batch-job-from-a-rest-endpoint-b7182e7dd7f7
Launch Spring Batch job from a REST endpoint 🚀 | by theoneamin | Medium
May 9, 2022 - Launch Spring Batch job from a REST endpoint 🚀 In this article, we’ll take a look at how to launch a spring batch job from a REST endpoint. We’ll do this by first disabling jobs from running …
🌐
GitHub
github.com › chaitanyaankam › spring-batch-using-rest
GitHub - chaitanyaankam/spring-batch-using-rest: Spring Batch and Spring REST example; Batch controlled and monitored through REST API's exposed
Spring Batch and Spring REST example (Loading Data form CSV to Database using spring batch framework). Batch controlled and monitored through REST API's exposed (Starting, Aborting, Restarting and Monitoring). Resources loaded from Batch are exposed through Spring REST (Exposing Data loaded ...
Author   chaitanyaankam
🌐
GitHub
github.com › hvalfangst › spring-batch
GitHub - hvalfangst/spring-batch: HTTP-triggered Spring Batch tasklet job which performs ETL · GitHub
HTTP-triggered Spring Batch tasklet job which performs ETL - hvalfangst/spring-batch
Author   hvalfangst
🌐
GitHub
github.com › jehanzebqayyum › spring-batch-rest-client
GitHub - jehanzebqayyum/spring-batch-rest-client: spring batch rest client · GitHub
A spring boot app showcasing spring batch handling of multithreaded rest api calls.
Author   jehanzebqayyum
🌐
Petri Kainulainen
petrikainulainen.net › home › blog › spring batch tutorial: reading information from a rest api
Spring Batch Tutorial: Reading Information From a REST API - Petri Kainulainen
December 21, 2020 - If you want to read the input data of your batch job from a REST API, you can read this information by using the RestTemplate class. The next part of this tutorial describes how you can read the input data of your batch job from an Excel spreadsheet. P.S. You can get the example application ...
Find elsewhere
🌐
GitHub
github.com › jmformenti › spring-batch-rest-cli-example
GitHub - jmformenti/spring-batch-rest-cli-example: Example of execution same spring batch job via command line or REST Api · GitHub
batch-cli execute jobs via command line using Spring Boot. batch-rest execute jobs via REST Api using spring-batch-rest and Spring Boot.
Author   jmformenti
🌐
Medium
medium.com › @andrejtaneski › using-spring-batch-in-a-rest-api-application-493b812d80d1
Using Spring Batch in a REST API Application | by Andrej Taneski | Medium
March 24, 2023 - This is where we can store data that we need in order to have a trail of from each step. After adding Spring Batch as a dependency and making sure it is pulled to your local repository, you can start using it by creating the base configuration which will enable us to add steps and jobs later.
🌐
GitHub
github.com › zeroFruit › spring-batch-schedule
GitHub - zeroFruit/spring-batch-schedule: spring batch schedulable job which call external REST api
spring batch schedulable job which call external REST api - zeroFruit/spring-batch-schedule
Starred by 4 users
Forked by 2 users
Languages   Java 45.3% | Shell 30.9% | Batchfile 23.8% | Java 45.3% | Shell 30.9% | Batchfile 23.8%
🌐
Spring
spring.io › guides › gs › batch-processing
Getting Started | Creating a Batch Service
This guide walks you through the process of creating a basic batch-driven solution.
🌐
Maven Repository
mvnrepository.com › artifact › com.github.chrisgleissner › spring-batch-rest-api
Maven Repository: com.github.chrisgleissner » spring-batch-rest-api
Home » com.github.chrisgleissner » spring-batch-rest-api · Spring Batch REST API · Central (20) Central · Atlassian External · Atlassian · WSO2 Releases · WSO2 Public · Hortonworks · Mulesoft · JCenter · KtorEAP · Sonatype · 2025 New · MacBook Pro M5 ·
🌐
GitHub
github.com › pkainulainen › spring-batch-examples › blob › master › spring › src › main › java › net › petrikainulainen › springbatch › rest › in › RESTStudentReader.java
spring-batch-examples/spring/src/main/java/net/petrikainulainen/springbatch/rest/in/RESTStudentReader.java at master · pkainulainen/spring-batch-examples
import org.springframework.web.client.RestTemplate; · import java.util.Arrays; import java.util.List; · /** * This class demonstrates how we can read the input of our batch job from an · * external REST API. * * @author Petri Kainulainen · */ class RESTStudentReader implements ItemReader<StudentDTO> { ·
Author   pkainulainen
🌐
Medium
prateek-ashtikar512.medium.com › spring-batch-read-from-rest-api-990d03208c1
Spring Batch — read from REST API - Prateek
September 4, 2023 - @SpringBootApplication @EnableBatchProcessing @EnableScheduling public class SpringBatchExampleApplication implements CommandLineRunner { @Autowired private Job job; @Autowired private JobLauncher jobLauncher; @Bean RestTemplate restTemplate() { return new RestTemplate(); } public static void main(String[] args) { SpringApplication.run(SpringBatchExampleApplication.class, args); } @Override public void run(String... args) throws Exception { jobLauncher.run(job, newExecution()); } private JobParameters newExecution() { Map<String, JobParameter> parameters = new HashMap<>(); JobParameter paramet
🌐
YouTube
youtube.com › watch
Spring Batch with REST API and SQL DB using Spring Boot - YouTube
In this video, I will explain the architecture, when to use spring batch, how to trigger the spring batch either automatically or by rest API with SQL DB, an...
Published   September 12, 2022
🌐
Keitaro
keitaro.com › insights › 2023 › 03 › 23 › using-spring-batch-in-a-rest-api-application
Using Spring Batch in a REST API Application – Keitaro
March 23, 2023 - This is where we can store data that we need in order to have a trail of from each step. After adding Spring Batch as a dependency and making sure it is pulled to your local repository, you can start using it by creating the base configuration, which will enable us to add steps and jobs later.
🌐
GitHub
github.com › tuxdevelop › spring-batch-lightmin
GitHub - tuxdevelop/spring-batch-lightmin: Spring Batch Administration @ Spring Boot Stack · GitHub
@EnableLightminBatchJpa configures the JPA specific BatchConfigurer · The Remote Repository Server is a Spring Boot application which provides a REST API for clients.
Starred by 136 users
Forked by 47 users
Languages   Java 80.7% | HTML 19.0%