Spring Batch and MongoDB — Reading and Writing from Excel file
In this story, I’ll explain you how to read and write an Excel file with Spring Batch using a custom reader and writer.
We are going to create a simple Spring boot application that demonstrates how to use Spring batch with mongoDB.
Prerequistes
- Spring Boot 2.4
- Maven 3.6.1.
- JAVA 8.
- Mongo 4.4.
- Apache poi 4.1.2
Spring Batch Overview
Spring batch is a Spring Framework library that processes large amounts of data without human intervention. Spring Batch has support for CSV, XML files, but natively doesn’t support XLSX files. It is not designed for use as a scheduling framework. However, it can be used in combination with a scheduling framework such as Quartz, Control-M, etc.
You can achieve storing data to XLSX with support of Apache POI SXSSF API.
Getting Started
As an example, we will create a Spring Batch job that can import employee information from an Excel file. This file contains information like firstname, lastname, number, email address and department. When we read the employee information from an Excel file, we have insert…