CommandLineRunners in Spring Shell
Published on March 25, 2022
Spring Shell uses a CommandLineRunner
blocking the main thread in order to run the interactive communication with the user.
Other CommandLineRunners
without any defined @Order()
or a lower priority will not be executed before entering the interactive shell. They are only executed once the Spring Shell is executed with the exit
command.
In order to have runners run before the shell they need an @Order()
lower than 0.
@Component
@Order(-1) // Run before Spring Shell
public class DbSeedRunner implements CommandLineRunner
Source: