http://sourceforge.net/projects/springframework (spring 的下载链接)
Resource resource=new ClassPathResource("appcontext.xml");
BeanFactory factory=new XmlBeanFactory(resource);
HelloWorld helloWorld =(HelloWorld) factory.getBean("beanName");
本文通过具体示例展示了如何使用Spring框架加载配置文件并创建指定的Bean实例。首先通过ClassPathResource获取到配置文件appcontext.xml,然后利用XmlBeanFactory进行Bean的实例化。
http://sourceforge.net/projects/springframework (spring 的下载链接)
Resource resource=new ClassPathResource("appcontext.xml");
BeanFactory factory=new XmlBeanFactory(resource);
HelloWorld helloWorld =(HelloWorld) factory.getBean("beanName");
614

被折叠的 条评论
为什么被折叠?