posts - 120,  comments - 19,  trackbacks - 0
          <2006年6月>
          28293031123
          45678910
          11121314151617
          18192021222324
          2526272829301
          2345678

          常用鏈接

          留言簿(6)

          我參與的團隊

          隨筆分類

          隨筆檔案

          文章檔案

          休閑娛樂

          外文網站

          好的技術論壇

          搜索引擎

          經典Blog

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          在讀spring in aciton 時,他用的BeanFactory factory = new XmlBeanFactory(new FileInputStream("hello.xml"));
          可是現在的用的1.2.6版本的構造器(XmlBeanFactory)只能接收Resource接口了,所以調不出來是正常的事情,假設現在有一個文件hello.xml
          讀取方法

          1:ApplicationContext cx=new FileSystemXmlApplicationContext("hello.xml");//指定的路徑去找文件
          2:ApplicationContext factory = new ClassPathXmlApplicationContext("hello.xml");//還會在classpath去找
          3:Resource fa = new FileSystemResource("hello.xml");
          ? ?BeanFactory factory=new XmlBeanFactory(fa);
          4:這個要設制classpath了,麻煩
           ?Resource res = new ClassPathResource("com/springinaction/chapter01/hello/hello.xml");
           ?BeanFactory factory=new XmlBeanFactory(res);
          好了,用了上面那種方法都可以調用getBean("your bean name")了,
          eg:?BeanFactory factory=new XmlBeanFactory(fa);
          ????? hello he=(hello)factory.getBean("hello");
          ????????????? he.getHello();


          posted on 2006-06-08 09:12 阿成 閱讀(265) 評論(0)  編輯  收藏 所屬分類: Spring
          主站蜘蛛池模板: 郁南县| 任丘市| 偃师市| 台江县| 喀喇| 滕州市| 满城县| 平和县| 彭阳县| 吐鲁番市| 宁波市| 义乌市| 三明市| 三门县| 磐安县| 鄂尔多斯市| 泗阳县| 台中县| 合水县| 柳州市| 北宁市| 南和县| 盐亭县| 义乌市| 于都县| 昌宁县| 大冶市| 教育| 鱼台县| 西藏| 进贤县| 乡城县| 禄劝| 左云县| 通海县| 延安市| 正宁县| 澜沧| 武乡县| 定襄县| 靖宇县|