1

How do we know bean is managed by spring container?For example,some bean maybe not scaned,and how do we know(some bean using @controller may not throw an error).Is any tool to scan the program memory and show all registered beans?Is there any way to query beans by name or other condition? That's what i want to know, i have been searching from google and nothing found.

Dolphin
  • 29,069
  • 61
  • 260
  • 539
  • If you're using boot, you can enable the [actuator features](http://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-endpoints.html) and access the `/beans` endpoint. – Morfic Oct 18 '16 at 13:16

2 Answers2

2

You can get list of all beans managed by spring container using Application Context.

context.getBeanDefinationNames();
0

You can use getBean method from the ApplicationContext.

Nikem
  • 5,716
  • 3
  • 32
  • 59