PathMatchingResourcePatternResolver (spring) Usage

余生颓废 提交于 2019-12-08 15:58:33

问题


I'm using :

PathMatchingResourcePatternResolver rr = new ...;
rr.getResources("classpath*:**/*.class")

to get all the classes from the classpath that is made of directories and jars. The call returns only classes from the directories; JAR files are ignored. The following call returns classes from JARs :

rr.getResources("classpath*:org/**/*.class")

Is that possible to get all the classes without knowing the base package name ?


回答1:


It is mentioned in the documentation that when using "classpath*:" prefix along with ant-style patterns atleast one root directory needs to be mentioned before the patterns starts and that it is a limitation in the JDK's ClassLoader.getResources() method. If the root directory is not mentioned then it retrieves files from the root of the expanded directories only.

So unfortunately you are out of luck here.



来源:https://stackoverflow.com/questions/11047672/pathmatchingresourcepatternresolver-spring-usage

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!