英文:
Where should the file root-context.xml for a Java Hibernate project be located
问题
我有一个刚安装的 Eclipse 版本:版本:2020-09(4.17.0)
我正在尝试构建并部署一个 Spring Web 应用到 Tomcat 7。当我执行 maven-install 时,出现以下错误:
由于找不到 class path 资源 [root-context.xml],无法打开位于类路径资源 [root-context.xml] 的 XML 文档的 IOException;嵌套异常是 java.io.FileNotFoundException: 无法打开类路径资源 [root-context.xml],因为它不存在。
我已将 root-context.xml 添加到 src/main/webapp/WEB-INF/spring,并将其添加到我的构建路径中。我不知道是否需要将它移动到其他地方。
英文:
I have a freshly installed version of eclipse: Version: 2020-09 (4.17.0)
I am trying to build and deploy a spring web application to Tomcat 7. I'm getting the following error when I do a 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
I've added root-context.xml in src/main/webapp/WEB-INF/spring to my build path. I don't know if I need to move it somewehre.
答案1
得分: 1
尝试将 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>
英文:
Try moving root-context.xml to src/main/resources directory, it will be included in the eclipse target folder and run correctly.
and add this piece on yout pom.xml if you have test add in the test path
<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>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论