java.io.FileNotFoundException: class path resource [applicationContext.xml] cannot be opened because it does not exist
at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:172)
public class BeanFactoryTest {
public static void main(String[] args) {
Resource resource = new ClassPathResource("applicationContext.xml");
BeanFactory beanFactory = new XmlBeanFactory(resource);
DemoBean db = (DemoBean) beanFactory.getBean("test");
db.foo();
}
}
ClassPathResource从src下开始寻找,将applicationContext.xml文件放到src下即可解决问题。