My folder structure looks like:
project
subproject
src
- main
-java
- test
-java
-resources
-spring
context.xml
when I try to use @ContextConfiguration(locations={"file:src/test/resources/spring/context.xml"})
my ide (intellij) shows cannot resolve directory
. However, if I change the code to
@ContextConfiguration(locations={"/spring/context.xml"})
or
@ContextConfiguration(locations={"classpath:/spring/context.xml"})
The error disappears.
My original setting already has the following configure in pom.xml
<testResources>
<testResource>
<directory>src/test/resources</directory>
</testResource>
</testResources>
What could be the problem?
Try loading test resources like:
@TestPropertySource(properties = { "spring.config.location=classpath:spring/context.xml" })
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.