Print all the Spring beans that are loaded

前端 未结 8 1612
说谎
说谎 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()));
        }
    }
    
    0 讨论(0)
  • 2020-11-28 04:00

    With Spring Boot and the actuator starter

    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>
    

    you can check the endpoint /beans

    0 讨论(0)
提交回复
热议问题