Spring Boot Command Line Runner for Building Command Line Utility

If you need to run some specific code once the SpringApplication has started, you can implement the ApplicationRunner or CommandLineRunner interfaces. Both interfaces work in the same way and offer a single run method which will be called just before SpringApplication.run(…​) completes.

 

The CommandLineRunner interfaces provides access to application arguments as a simple string array, whereas the ApplicationRunner uses the ApplicationArguments interface.

 

Example:

import org.springframework.boot.*

import org.springframework.stereotype.*

 

@Component

public class MyBean implements CommandLineRunner {

 

    public void run(String... args) {

        // Do something...

    }

 

}

 

Read more @
http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#boot-features-command-line-runner.

 

Search the Web

Custom Search

Searches whole web. Use the search in the right sidebar to search only within javajee.com!!!