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