spring五:获取容器中对象信息
生活随笔
收集整理的這篇文章主要介紹了
spring五:获取容器中对象信息
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
// 獲取容器中對(duì)象信息@Testpublic void test2(){String configLocation = "applicationContext.xml"; // 類路徑的根目錄// 會(huì)創(chuàng)建對(duì)象ApplicationContext ctx = new ClassPathXmlApplicationContext(configLocation);// 獲取容器中定義的對(duì)象個(gè)數(shù)int counts = ctx.getBeanDefinitionCount();System.out.println("容器中定義對(duì)象個(gè)數(shù):"+counts);// 獲取容器中定義的對(duì)象的名稱String names[] = ctx.getBeanDefinitionNames();for(String name : names){System.out.println("容器中定義對(duì)象名稱:"+name);}}
?
總結(jié)
以上是生活随笔為你收集整理的spring五:获取容器中对象信息的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 前端一HTML:十三:css的三大特性
- 下一篇: spring6:bean的生命始末方法