我正在学习Java和Spring MVC。我找到了这段代码:
@ContextConfiguration(locations = { "classpath: com/myname/spring/junit-context.xml" })我知道com/myname/spring/junit-context.xml是一个相对路径。我的问题是:在web应用程序的上下文中,它与什么相关?
发布于 2015-10-27 04:21:02
它相对于类路径(这就是为什么它以类路径为前缀)。您的类路径中可以有多个文件夹和jars,Spring将在所有这些文件夹和jars中搜索资源文件。
发布于 2016-04-27 09:07:29
@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->文件名
仅文件夹结构
https://stackoverflow.com/questions/33351803
复制相似问题