[英]Spring MVC @ContextConfiguration
我正在學習Java和Spring MVC。 我發現此代碼:
@ContextConfiguration(locations = { "classpath: com/myname/spring/junit-context.xml" })
我了解com / myname / spring / junit-context.xml是相對路徑。 我的問題是:在Web應用程序的上下文中,相對TO是什么?
它是相對於類路徑的(這就是為什么它以類路徑作為前綴的原因)。 您可以在類路徑中有幾個文件夾和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 /彈簧
com-> myname-> spring->文件名
只是文件夾結構
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.