有什么办法可以查询spring容器的bean [英] Is there any way to query bean of spring container

查看:200
本文介绍了有什么办法可以查询spring容器的bean的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们如何知道bean是由spring容器管理的?例如,某些bean可能没有被扫描,以及我们如何知道(某些使用@controller的bean不会抛出错误).显示所有已注册的bean?是否可以通过名称或其他条件查询bean?这就是我想知道的,我一直在从Google搜索,但没有找到.

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.

推荐答案

您可以使用Application Context获取由spring容器管理的所有bean的列表.

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

context.getBeanDefinationNames();

这篇关于有什么办法可以查询spring容器的bean的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆