getBeanDefinitionNames()
public static void main(String[] args){ ApplicationContext context = new ClassPathXmlApplicationContext( "appContext.xml"); //載入appContext.xml檔案 String[] beanNames = context.getBeanDefinitionNames(); //獲取所有JavaBean的名稱 for(String name:beanNames){ System.out.println("JavaBean名稱:"+name); } }