From the course: Spring: Spring Batch

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Solution: Writing a JSON file

Solution: Writing a JSON file

From the course: Spring: Spring Batch

Start my 1-month free trial

Solution: Writing a JSON file

(soothing music) - [Instructor] So let's take a look at one solution to the challenge. I hope you found it enjoyable. In order to complete the challenge, we needed to switch our item writer implementation. Currently the implementation we have writes to a database, and we wanted to write to a JSON file. So, let's go ahead and remove the current configuration of our item writer bean, and then we're going to leverage a new object, the JsonFile Item Writer builder. And this will help us configure our new item writer, which is capable of writing JSON to a file on the file system. Now when we construct the JSON File Item writer builder using its constructor, we need to supply a generic type argument which is the type of the POJO that we we would like to write to our JSON file. And then from there, we have to supply a JSON object marshaller. In this case, we're going to be using Spring's Jackson support. And we'll use…

Contents