Spring Boot Application CommandLineRunner

Sometimes, it is useful to run a command after the Spring Application starts. This can be achieved by implementing the CommandLineRunner and overriding the run method. An example is below.


@Slf4j
@SpringBootApplication
public class ExampleCLRApplication implements CommandLineRunner {
  public static void main(String[] args) {
    SpringApplication.run(OrgServiceAdapterApplication.class, args);
  }

  @Override
  public void run(String... args) throws Exception {
    log.info("run...");
  }
}

Leave a Reply

Your email address will not be published. Required fields are marked *