Spring在类路径中找不到文件,但它就在war文件的根目录下

Spring在类路径中找不到文件,但它就在war文件的根目录下,spring,eclipse,maven,classloader,Spring,Eclipse,Maven,Classloader,我有一个使用标准Maven web应用程序布局的项目,它部署在EclipsePhoton中的Tomcat8.5中,并有最新的更新 在src\main\webapp\WEB-INF\applicationContext.xml中,有一个 我验证了通常位于src/main/resources中的other-spring-stuff.xml,它出现在mvn安装生成的WAR的根目录中 但在Eclipse中尝试在Tomcat中运行应用程序时,我得到: 20:37:17 SEVERE: Servlet [s

我有一个使用标准Maven web应用程序布局的项目,它部署在EclipsePhoton中的Tomcat8.5中,并有最新的更新

在src\main\webapp\WEB-INF\applicationContext.xml中,有一个

我验证了通常位于src/main/resources中的other-spring-stuff.xml,它出现在mvn安装生成的WAR的根目录中

但在Eclipse中尝试在Tomcat中运行应用程序时,我得到:

20:37:17 SEVERE: Servlet [servletSpringDispatcher] in web application [/myapp] threw load() exception - 2018-08-27 @{org.apache.catalina.core.StandardContext loadOnStartup} 
java.io.FileNotFoundException: class path resource [spring.xml] cannot be opened because it does not exist
    at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:172)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:330)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:304)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:181)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:217)
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.importBeanDefinitionResource(DefaultBeanDefinitionDocumentReader.java:227)
我真的不知道这是Maven、Eclipse还是Spring的问题

这是什么原因造成的?这实际上是在一个直到昨天还可以正常工作的项目中,项目配置没有任何变化。

原始问题spring.xml未找到和次要问题web.xml缺失的错误报告都通过以下步骤得到解决:

从工作区中删除项目,但将其保留在文件系统中 转到项目的文件系统位置并删除.project、.classpath和.settings/ 将项目重新导入Eclipse,选择现有Maven项目作为项目类型 要防止再次发生:从git中删除.project、.classpath和.settings/*并将它们添加到.gitignore
我认为根本原因是签入repo的这些特定于Eclipse的配置文件中的一个已经损坏,并且/或者与我的Eclipse版本不兼容。另外:这些文件似乎包含对工作区中事物的绝对路径引用,因此当项目未经修改签出到其他位置时,这些文件会中断。

为什么要查找spring.xml而不是other-spring-stuff.xml?这只是一个例子,还是你重命名了这个文件?我只是想让这个问题更容易解释。实际文件是spring.xml您的other-spring-stuff.xml仍在src/main/resources下吗?在没有/I决定删除项目并从主分支重新签出的情况下,您可以尝试classpath*:other-spring-stuff.xml吗。现在,更改为web.xml的错误丢失,并设置为true,如以下未回答的问题:此处已回答