Java springmvc@ContextConfiguration

Java springmvc@ContextConfiguration,java,spring-mvc,Java,Spring Mvc,我正在学习Java和SpringMVC。我发现这个代码: @ContextConfiguration(locations = { "classpath: com/myname/spring/junit-context.xml" }) 我知道com/myname/spring/junit-context.xml是一个相对路径。 我的问题是:在web应用程序的上下文中,它是相对于什么的?它是相对于类路径的(这就是为什么它以类路径作为前缀)。在类路径中可以有几个文件夹和JAR,Spring将在所有文

我正在学习Java和SpringMVC。我发现这个代码:

@ContextConfiguration(locations = { "classpath: com/myname/spring/junit-context.xml" })
我知道com/myname/spring/junit-context.xml是一个相对路径。
我的问题是:在web应用程序的上下文中,它是相对于什么的?

它是相对于类路径的(这就是为什么它以类路径作为前缀)。在类路径中可以有几个文件夹和JAR,Spring将在所有文件夹和JAR中搜索资源文件

@ContextConfiguration(locations = {
    "file:src/main/webapp/WEB-INF/spring/root-context.xml",
    "file:src/main/webapp/WEB-INF/spring/security-context.xml",
    "file:src/main/webapp/WEB-INF/spring/appServlet/servlet-context.xml" })
webapp->WEB-INF->spring->ContextConfiguration文件名


com/myname/spring

com->myname->spring->file name

只是文件夹结构