今天繼續學習spring,按照《Spring 開發指南》go on,結果到22頁的時候發現有如下代碼
InputStream is = new FileInputStream("bean.xml");
XmlBeanFactory factory = new XmlBeanFactory(is);
Action action = (Action) factory.getBean("TheAction");
使用junit4測試發送,發現有錯誤,但是依舊可以運行得到預期的結果。
查看API以及去網上baidu了一圈,發現底層的確沒有xmlbeanfactory(inputstream )的方法,但是不知道為什么夏老師依舊這樣寫?
我根據API中方法,這樣實現
Resource in = new FileSystemResource("bean1.xml");
XmlBeanFactory factory = new XmlBeanFactory((Resource) in);
Action action = (Action) factory.getBean("TheAction");
System.out.println(action.execte("xixi hha "));
不知道,這個算不算是《Spring 開發指南》中的又一BUG
等那天有時間 在單位找找牛人問問。
不知道你發現這個問題么?說說你是怎么理解的,大家一起交流一下么?