Last active
May 8, 2023 07:17
-
-
Save sandipchitale/ae4cf6c41833e67abbbcb1300b28f314 to your computer and use it in GitHub Desktop.
Dump bean names and class names #springframework
This file contains hidden or 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
@Component | |
public static class CLR implements CommandLineRunner, ApplicationContextAware { | |
private ApplicationContext applicationContext; | |
@Override | |
public void run(String... args) throws Exception { | |
if (this.applicationContext != null) { | |
String[] beanDefinitionNames = this.applicationContext.getBeanDefinitionNames(); | |
for (String beanDefinitionName : beanDefinitionNames) { | |
System.out.println("Bean: " + beanDefinitionName + " = " | |
+ this.applicationContext.getBean(beanDefinitionName).getClass().getName()); | |
} | |
} | |
} | |
@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