Printing all the loaded beans in Springboot

@SpringBootApplication
public class BlogApplication implements CommandLineRunner {
  @Autowired
  ApplicationContext applicationContext;
  public static void main(String[] args) {
    SpringApplication.run(BlogApplication.class, args);
  }
  @Override
  public void run(String...args) throws Exception {
    String[] beans = applicationContext.getBeanDefinitionNames();
    Arrays.sort(beans);
    for (String bean: beans) {
      System.out.println(bean);
    }
  }
}

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *