Spring 类路径前缀区别 [英] Spring classpath prefix difference
问题描述
记录 此处说明
这个特殊的前缀指定所有匹配的类路径资源必须获得给定的名字(在内部,这基本上发生通过 ClassLoader.getResources(...)调用),然后合并形成最终应用上下文定义.
This special prefix specifies that all classpath resources that match the given name must be obtained (internally, this essentially happens via a ClassLoader.getResources(...) call), and then merged to form the final application context definition.
有人能解释一下吗?
使用 classpath*:conf/appContext.xml
与不带星号的 classpath:conf/appContext.xml
有什么区别.
What is the difference between using classpath*:conf/appContext.xml
as opposed to classpath:conf/appContext.xml
without the asterisk.
推荐答案
简单定义
classpath*:conf/appContext.xml
只是意味着 conf
文件夹下的 所有 appContext.xml 文件类路径将被选取并加入到一个大的应用程序上下文中.
The classpath*:conf/appContext.xml
simply means that all appContext.xml files under conf
folders in all your jars on the classpath will be picked up and joined into one big application context.
相比之下,classpath:conf/appContext.xml
将只加载一个这样的文件...在您的类路径中找到的第一个.
In contrast, classpath:conf/appContext.xml
will load only one such file... the first one found on your classpath.
这篇关于Spring 类路径前缀区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!