Skip to content

Instantly share code, notes, and snippets.

@sandipchitale
Created April 24, 2021 19:15
Show Gist options
  • Save sandipchitale/af1e4607f63f2bce9bedbcbf04e581b0 to your computer and use it in GitHub Desktop.
Save sandipchitale/af1e4607f63f2bce9bedbcbf04e581b0 to your computer and use it in GitHub Desktop.
Dump all bean names #springboot
@Component
public class CommandLineAppStartupRunner implements CommandLineRunner, ApplicationContextAware {
private ApplicationContext applicationContext;
@Override
public void run(String... args) throws Exception {
String[] beanNames = this.applicationContext.getBeanDefinitionNames();
Arrays.stream(beanNames).forEach((beanName) -> {
System.out.println(beanName);
});
}
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
this.applicationContext = applicationContext;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment