尝试在独立java中读取applicationContext.xml时出错

时间:2014-02-24 09:32:41

标签: spring

ApplicationContext context=new ClassPathXmlApplicationContext("classpath:applicationContext.xml");
InvGroupDelegate  igcd = (InvGroupDelegate) context.getBean("invGroupDelegate");

给出错误:

Caused by: 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:157)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:328)

appContext文件存在于myProject / properties中     这也会添加到构建路径中的' Src文件夹中。

1 个答案:

答案 0 :(得分:0)

解决了它。是一个日食问题。关闭项目并重新开始。然后清理一切并再次构建。事情很好。