0

从 xml 文件中读取 bean 定义时,以下两种方法中哪种方法最好。我记得读到过Resource,使用它很快或类似的东西,但不知道确切。

Resource rs = new ClassPathResource("hello.xml");
BeanFactory  factory = new XmlBeanFactory(rs);

或者

BeanFactory  factory = new XmlBeanFactory(new FileInputStream("myBean.xml"));
4

1 回答 1

0

您可能更喜欢http://static.springsource.org/spring/docs/2.5.x/api/org/springframework/context/support/ClassPathXmlApplicationContext.html只是因为这个类实现了 BeanFactory 接口并且有更多好东西。

于 2012-07-27T12:45:37.457 回答