Spring Boot Strapping

If you need to initialise your application, there are two ways to do this. You can get your initialisation class to implement either:

  • ApplicationListener<ContextRefreshedEvent>. @Override the onApplicationEvent method

  • CommandLineRunner. @Override the run method.

Boot strapping is typically used to initialise the application database or any other setup activities.

../../_images/bootstrap01.png

NOTE for Lombok: In IntelliJ, install the Lombok plugin before using the above @Sl4j.

../../_images/bootstrap02.png

application.properties

ANSI Console

The entry spring.output.ansi.enabled=ALWAYS placed in the application.properties enables coloured output on the java console to make debugging easier.

Logging Level

The entry logging.level.<package-root>=DEBUG must be placed in applicaton.properties to enable logging level to DEBUG.

Run from Command Line

  • To download all maven packages, execute a mvn clean install.

  • To run the application, issue mvn spring-boot:run.

Windows

To ensure mvn finds the correct JDK in Windows, edit the mvnw.cmd file and set the JAVA_HOME environment variable correctly.

../../_images/bootstrap03.png