Spring getbeannamesfortype method: get bean name by type
•
Java
getBeanNamesForType(Class type)
Example
public static void main(String[] args){ ApplicationContext context = new ClassPathXmlApplicationContext( "appContext.xml"); //加载appContext.xml文件 String[] beanNames = context.getBeanNamesForType(Date.class); //返回所有JavaBean的名称 for(String name:beanNames){ System.out.println("JavaBean名称:"+name); } }
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码