How to display all beans loaded by Spring Boot

In Spring Boot, you can use appContext.getBeanDefinitionNames() to get all the beans loaded by the Spring container. 1. CommandLineRunner as Interface Application.java package com.mkyong; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.CommandLineRunner; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.ApplicationContext; import java.util.Arrays; @SpringBootApplication public class Application implements CommandLineRunner { @Autowired private ApplicationContext appContext; public static void main(String[] args) throws Exception { …

Read more