首页 > 解决方案 > Java Hibernate 项目的文件 root-context.xml 应该放在哪里

问题描述

我有一个新安装的 eclipse 版本:版本:2020-09 (4.17.0) 我正在尝试构建 Spring Web 应用程序并将其部署到 Tomcat 7。执行 maven-install 时出现以下错误:

Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [root-context.xml]; nested exception is java.io.FileNotFoundException: class path resource [root-context.xml] cannot be opened because it does not exist

我已将 src/main/webapp/WEB-INF/spring 中的 root-context.xml 添加到我的构建路径中。我不知道我是否需要将它移到某个地方。

标签: javaspring

解决方案


尝试将 root-context.xml 移动到 src/main/resources 目录,它将包含在 eclipse 目标文件夹中并正确运行。

如果您在测试路径中有测试添加,则在您的 pom.xml 中添加这部分

<build>
....
<resources>
    <resource>
        <directory>src/main/resources</directory>
        <filtering>true</filtering>
    </resource>
</resources>
<testResources>
    <testResource>
        <directory>src/test/resources</directory>
        <filtering>true</filtering>
    </testResource>
</testResources>
....
</build>

推荐阅读