天天看點

classpath 和 classpath*的 差別:

classpath:隻會到你指定的class路徑中查找找檔案; 

classpath*:不僅包含class路徑,還包括jar檔案中(class路徑)進行查找.

舉個簡單的例子,若web.xml中是這麼定義的:

1

2

3

4

5

6

7

那麼在META-INF/spring這個檔案夾底下的所有applicationContext.xml都會被加載到上下文中,這些包括META-INF/spring檔案夾底下的 applicationContext.xml,META-INF/spring的子檔案夾的applicationContext.xml以及jar中的applicationContext.xml。

而若在web.xml中定義的是:

那麼隻有META-INF/spring底下的applicationContext.xml會被加載到上下文中。