public class MyApplication implements CommandLineRunner
@Resource
private ApplicationContext appContext;
/**
* CommandLineRunner ,打印spring容器中的bean
*
* @param args 参数
*/
@Override
public void run(String... args) {
String[] beans = appContext.getBeanDefinitionNames();
Arrays.sort(beans);
for (String bean : beans) {
log.info(bean + " is type of " + appContext.getBean(bean).getClass());
}
}