The classpath*: prefix

来源:互联网 发布:滚雪球官网数据档案 编辑:程序博客网 时间:2024/06/08 05:15
 

http://static.springsource.org/spring/docs/1.2.x/reference/resources.html

4.7.2. The classpath*: prefix

When constructing an XML-based application context, a location string may use the special classpath*: prefix:

ApplicationContext ctx =    new ClassPathXmlApplicationContext("classpath*:conf/appContext.xml");

This special prefix specifies that all classpath resources that match the gven name should be obtained (internally, this essentially happens via aClassLoader.getResources(...) call), and then merged to form the final application context definition.

One use for this mechanism is when doing component-style application assembly. All components can 'publish' context definition fragments to a well-known location path, and when the final application context is created using the same path prefixed viaclasspath*:, all component fragments will be picked up automatically.

Note that this special prefix is specific to application contexts, and is resolved at construction time. It has nothing to do with theResource type itself. It's not possible to use the classpath*: prefix to construct an actual Resource, as a resource points to just one resource at a time.

原创粉丝点击