This is a simple Spring Boot application that demonstrates how to process CSV file using Spring batch. It provides endpoint for invoking batch job to process sample CSV file provided in resources.
- CSV File Processing: Process sample CSV file through a REST endpoint for processing.
- Data Persistence: Persist processed data into an H2 in-memory database using JPA.
- Custom Data Processor: Modify data before persisting it using a custom ItemProcessor.
- Job Listener: Log messages before and after the job process using a JobExecutionListener.
- Easy Configuration: Configure input/output paths, database properties, and batch job settings in the
application.properties
file. - Dynamic Chunk Processing: Process data in chunks to handle large files efficiently.
- Java
- Spring Boot
- Spring Batch
- Spring Data JPA
- H2 Database
- Java 17 or higher installed on your machine
- Maven installed on your machine
- Clone this repository to your local machine:
git clone https://github.com/harshrp/springboot3-batch-csv-processor.git
- Navigate to the project directory:
cd springboot3-batch-csv-processor
- Build the project using Maven:
mvn clean package
- Run the application:
-
Using maven
mvn spring-boot:run
-
From jar file Create a jar file using 'mvn clean install' command and then execute
java -jar target/<jar_filename>.jar
-
Directly from IDE
Right click on BatchCsvProcessorApplication.java and click on 'Run' option
- Once the application is running, you can access the endpoints using a REST client or any HTTP client library.
- URL:
/api/v1/processCustomer
- Method:
GET
- Description: Endpoint to process sample CSV file provided in resources.
- The H2 in-memory database is used for demonstration purposes. You can switch to another database by configuring the
application.properties
file accordingly.
This project is licensed under the MIT License - see the LICENSE file for details.