Question: I'm learning Spring boot. What's some typical use cases for ApplicationRunner or any runner interface? 

```
import org.junit.jupiter.api.Test;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.test.context.SpringBootTest;

@SpringBootTest
class PersistencedemoApplicationTests implements ApplicationRunner {

    @Test
    void contextLoads() {
    }

    @Override
    public void run(ApplicationArguments args) throws Exception {
       // load initial data in test DB
    }
}

```

This is one case I'm aware of. Anything else?

Answer: 
These runners are used to run the logic on application startup, for example spring boot has [ApplicationRunner](https://docs.spring.io/spring-boot/docs/current/api/org/springframework/boot/ApplicationRunner.html)(Functional Interface) with `run` method

> 
> ApplicationRunner run() will get execute, just after applicationcontext is created and before spring boot application startup.
> 
> 
> ApplicationRunner takes ApplicationArgument which has convenient methods like getOptionNames(), getOptionValues() and getSourceArgs().
> 
> 
> 

And [CommandLineRunner](https://docs.spring.io/spring-boot/docs/current/api/org/springframework/boot/CommandLineRunner.html) is also a Functional interface with `run` method

> 
> CommandLineRunner run() will get execute, just after applicationcontext is created and before spring boot application starts up.
> 
> 
> It accepts the argument, which are passed at time of server startup.
> 
> 
> 

Both of them provides the same functionality and the only difference between `CommandLineRunner` and `ApplicationRunner` is `CommandLineRunner.run()` accepts `String array[]` whereas `ApplicationRunner.run()` accepts `ApplicationArguments` as argument. you can find more information with example [here](https://www.baeldung.com/running-setup-logic-on-startup-in-spring)
ApplicationRunner and CommandLineRunner are two interfaces Spring Boot provides to run any custom code just before application is fully started.

Spring-batch is a batch processing framework. This uses CommandLineRunner to register and start batch jobs at application startup.

You can also use this interface to load some master data into cache/perform health checks.

The use-case varies from application to application.