Last active
April 4, 2018 09:58
-
-
Save simonovAlexey/51166e11fe80c84f20c19527dd722788 to your computer and use it in GitHub Desktop.
Excample use a CommandLineRunner of Spring Boot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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); | |
for (String beanName : beanNames) { | |
System.out.println(beanName); | |
} | |
System.out.println("---"); | |
}; | |
} | |
//also supports: | |
// @Bean | |
// public CommandLineRunner commandLineRunner(TransactionServiceImpl transactionService) { | |
// return args -> { | |
// transactionService.init(); | |
// LOGGER.info("done"); | |
// }; | |
// } | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment