Print all the Spring beans that are loaded

前端 未结 8 1726
说谎
说谎 2020-11-28 03:05

Is there a way to print all the spring beans that are loaded on startup?I am using Spring 2.0.

8条回答
  •  暖寄归人
    2020-11-28 03:59

    public class PrintBeans {
        @Autowired
        ApplicationContext applicationContext;
    
        public void printBeans() {
            System.out.println(Arrays.asList(applicationContext.getBeanDefinitionNames()));
        }
    }
    

提交回复
热议问题