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...");
  }
}

Comments |0|

Legend *) Required fields are marked
**) You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>
In category: Uncategorized
Tagged with: , , , ,