开发者

Spring: search resources in inner jar

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 f开发者_运维百科iles 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).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜