Spring - CommandLineRunner interface

Table of Contents

CommandLineRunner interface

Interface used to indicate that a bean should run when it is contained within a SpringApplication. Multiple CommandLineRunner beans can be defined within the same application context and can be ordered using the Ordered interface or @Order annotation.

CommandLineRunner is a simple Spring Boot interface with a run method. Spring Boot will automatically call the run method of all beans implementing this interface after the application context has been loaded.

The run method is called after the application context is loaded, but before the execution of the main method is complete.

https://github.com/explorer436/programming-playground/tree/main/java-playground/springboot-commandlinerunner-example


Links to this note