Spring Boot Command Line program

programming, Spring Boot

Command line program w/ Spring Boot

To write a command line program (e.g. launched w/ static void main(String args[])), have the main application class implements org.springframework.boot.CommandLineRunner and implement the function:

public void run(String... args) throws Exception
Running the program can be done with:
java -jar myjar.jar args... 
or with:
 mvn spring-boot:run -Drun.arguments="args..."
See Link to stackoverflow.
One oddity is that, when looking at the logs, the actual running of the program looks like it all happens within the initialization phase of the program:
  .   ____          _            __ _ _
 /\ / ___'_ __ _ _(_)_ __  __ _    
( ( )___ | '_ | '_| | '_ / _` |    
 \/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |___, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v1.2.4.RELEASE)

2015-08-19 16:11:20 INFO  MyApplication:47 - Starting MyApplication on ...2015-08-19 16:11:20 DEBUG MyApplication:50 - Running with Spring Boot v1.2.4.RELEASE, Spring v4.1.6.RELEASE
2015-08-19 16:11:20 INFO  AnnotationConfigApplicationContext:510 - Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@6fa107f2: startup date [Wed Aug 19 16:11:20 PDT 2015]; root of context hierarchy
2015-08-19 16:11:20 INFO  ProfilesConfigFileLoader:185 - Skip unsupported property name region in profile [default].

... program runs here ...

2015-08-19 16:11:23 INFO  MyApplication:56 - Started MyApplication in 3.484 seconds (JVM running for 7.704)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------