views:

81

answers:

2

Documented here it states

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.

Can someone explain this?

What is the difference between using classpath*:conf/appContext.xml as opposed to classpath:conf/appContext.xml without the asterisk.

+3  A: 

The classpath*:... syntax is useful primarily when you want to build an application context from multiple bean definition files, using wildcard syntax.

For example, if you construct your context using classpath*:appContext.xml, the classpath will be scanned for every resource called appContext.xml in the classpath, and the bean definitions from all of them merged into a single context.

In contrast, classpath:conf/appContext.xml will obtain one and only one file called appContext.xml from the the classpath. If there is more than one, the others will be ignored.

skaffman
+3  A: 

SIMPLE DEFINITION

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.

In contrast, classpath:conf/appContext.xml will load only one such file... the first one found on your classpath.

eugener