O'Reilly logo

Hands-On High Performance with Spring 5 by Dinesh Radadiya, Prashant Goswami, Pritesh Shah, Subhash Shah, Chintan Mehta

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The ApplicationRunner way of initial data loading

We can also accomplish this using the ApplicationRunner interface. This interface is responsible for executing the code defined in the run method on application startup.

The following is the code for the ApplicationRunner interface's implementation:

package com.packt.springhighperformance.ch09.accountingservice;import java.util.stream.Stream;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.boot.ApplicationArguments;import org.springframework.boot.ApplicationRunner;import org.springframework.stereotype.Component;import com.packt.springhighperformance.ch09.accountingservice.models.Account;import com.packt.springhighperformance.ch09.accountingservice.repositories.AccountsRepository; ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required