24 lines
708 B
Java
24 lines
708 B
Java
|
|
package com.baeldung.displayallbeans;
|
||
|
|
|
||
|
|
import org.springframework.boot.SpringApplication;
|
||
|
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||
|
|
import org.springframework.context.ApplicationContext;
|
||
|
|
|
||
|
|
@SpringBootApplication
|
||
|
|
public class Application {
|
||
|
|
private static ApplicationContext applicationContext;
|
||
|
|
|
||
|
|
public static void main(String[] args) {
|
||
|
|
applicationContext = SpringApplication.run(Application.class, args);
|
||
|
|
|
||
|
|
displayAllBeans();
|
||
|
|
}
|
||
|
|
|
||
|
|
public static void displayAllBeans() {
|
||
|
|
String[] allBeanNames = applicationContext.getBeanDefinitionNames();
|
||
|
|
for (String beanName : allBeanNames) {
|
||
|
|
System.out.println(beanName);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|