Hibernate : include configuration files in WEB-INF in tests

时间:2015-07-29 08:54:33

标签: java hibernate testing

I have a web app and i am trying to set up the config for the unit tests. I have the following structure

project
-src/main/java
-src/main/resources
-src/test/java
-src/test/resources
-src
  -main
    -webapp
      -WEB-INF
        -spring
  -test
    -spring

All my spring configuration files are stored in the project\src\main\webapp\WEB-INF\spring directory. But the issue is that my test configuration files are stored in the project\src\test\spring directory.

For my tests i want to use some of the configuration files in the project\src\main\webapp\WEB-INF\spring directory but i keep getting a file not found exception when i try access them.

Is there a way to keep my configuration files in the WEB-INF folder but still visible to my test configuration files?

1 个答案:

答案 0 :(得分:1)

为什么要在project \ src \ main \ webapp \ WEB-INF \ spring中保留配置?
你必须使用:

  • 的src /主/资源
  • 的src /测试/资源


分别。
无论如何,在maven构建之后位于“src / main / resources”中的所有文件都将被移动到{appRoot} / WEB-INF文件夹。 然后从测试中,您将看到位于“src / main / resources”

中的所有文件