Skip to content

Instantly share code, notes, and snippets.

@simonovAlexey
simonovAlexey / CommandLineRunnerDemo
Last active April 4, 2018 09:58
Excample use a CommandLineRunner of Spring Boot
@Configuration
public class AppConfig {
// @return Spring Boot {@link CommandLineRunner} automatically
// run after app context is loaded.
@Bean
public CommandLineRunner commandLineRunner(ApplicationContext ctx) {
return args -> {
System.out.println("Let's inspect the beans provided by Spring Boot:\n");
String[] beanNames = ctx.getBeanDefinitionNames();
Arrays.sort(beanNames);