From the course: Spring Boot 3 Essential Training

Unlock this course with a free trial

Join today to access over 24,600 courses taught by industry experts.

CommandLineRunner interface

CommandLineRunner interface

- [Instructor] One of my favorite interfaces in the Spring Boot ecosystem and one that is very seldom talked about is the CommandLineRunner. Now, the CommandLineRunner is a very simple and effective tool when you need to do a finite amount of work. We don't always need to bring in Web or Rabbit or any of the other processes to do work, and this is a great way to do it. Sometimes we just want to do that work and we want it deployed as a task, but we want to use Spring in the most efficient way possible. So I feel in the Spring Boot use case that this is really where the CommandLineRunner interface shines at its best. Now, you can run it as a standalone Spring Boot application, or you can run it in another Spring Boot application, say a web application or a batch application. It allows you to do something like an admin, say you want to warm the cash or a batch process when your application starts. And as I alluded to, you can do a lot of this in standalone fashion as well. Now the…

Contents