I have a this war structure: Some.war
-WEB-INF
--lib
---library.jar
----some.xsd
----some2.xsd
And i want to get all xsd files in library.jar, but spring don't want to search it.
ContextLoaderListener.getCurrentWebApplicationContext()
.getResources("classpath*:**/*.xsd")
result is empty. I also tried: classpath:**/*.xsd
, **/*.xsd
.
How i can get all xsd files in jar using "ant" template (*/.xsd)?
The answer lies in the Spring docs:
4.7.2.3 Other notes relating to wildcards
Please note that "classpath*:" when combined with Ant-style patterns will only work reliably with at least one root directory before the pattern starts, unless the actual target files reside in the file system. This means that a pattern like "classpath*:*.xml" will not retrieve files from the root of jar files but rather only from the root of expanded directories. This originates from a limitation in the JDK's
ClassLoader.getResources()
method which only returns file system locations for a passed-in empty string (indicating potential roots to search).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With