Spring boot offers multiple options, for executing your code during the application startup. This post covers some of the ‘out of the box’ practices recommended by the Spring developers. There are mainly 3 options
- Option-1: Using @PostConstruct annotation
- Option-2: Using ApplicationRunner or Command Line Runner Interface
- Option-3: Using Spring Boot Events
In this article, we will cover all of the available options and look into the best practices dos and don'ts.