Is there any way to query bean of spring container [duplicate]

五迷三道 提交于 2019-12-24 06:44:59

问题


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.


回答1:


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

context.getBeanDefinationNames();



回答2:


You can use getBean method from the ApplicationContext.



来源:https://stackoverflow.com/questions/40108153/is-there-any-way-to-query-bean-of-spring-container

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!