@@ -568,10 +568,28 @@ strategy described above is used for the wildcard subpath.
568
568
Please note that `classpath*:` when combined with Ant-style patterns will only work
569
569
reliably with at least one root directory before the pattern starts, unless the actual
570
570
target files reside in the file system. This means that a pattern like
571
- `classpath*:*.xml` will not retrieve files from the root of jar files but rather only
572
- from the root of expanded directories. This originates from a limitation in the JDK's
571
+ `classpath*:*.xml` might not retrieve files from the root of jar files but rather only
572
+ from the root of expanded directories.
573
+
574
+ Spring's ability to retrieve classpath entries originates from the JDK's
573
575
`ClassLoader.getResources()` method which only returns file system locations for a
574
- passed-in empty string (indicating potential roots to search).
576
+ passed-in empty string (indicating potential roots to search). Spring evaluates
577
+ `URLClassLoader` runtime configuration and the "java.class.path" manifest in jar files
578
+ as well but this is not guaranteed to lead to portable behavior.
579
+
580
+ [NOTE]
581
+ ====
582
+ The scanning of classpath packages requires the presence of corresponding directory
583
+ entries in the classpath. When you build JARs with Ant, make sure that you do __not__
584
+ activate the files-only switch of the JAR task. Also, classpath directories may not
585
+ get exposed based on security policies in some environments, e.g. standalone apps on
586
+ JDK 1.7.0_45 and higher (which requires 'Trusted-Library' setup in your manifests; see
587
+ http://stackoverflow.com/questions/19394570/java-jre-7u45-breaks-classloader-getresources).
588
+
589
+ On JDK 9's module path (Jigsaw), Spring's classpath scanning generally works as expected.
590
+ Putting resources into a dedicated directory is highly recommendable here as well,
591
+ avoiding the aforementioned portability problems with searching the jar file root level.
592
+ ====
575
593
576
594
Ant-style patterns with `classpath:` resources are not guaranteed to find matching
577
595
resources if the root package to search is available in multiple class path locations.
0 commit comments