PathMatchingResourcePatternResolver(春季)用法 [英] PathMatchingResourcePatternResolver (spring) Usage
问题描述
我正在使用:
PathMatchingResourcePatternResolver rr = new ...;
rr.getResources("classpath*:**/*.class")
到从由目录和jar组成的类路径中获取所有类。该调用仅返回目录中的类。 JAR文件将被忽略。以下调用从JAR返回类:
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 ?
推荐答案
在文档,当使用 classpath *:前缀和蚂蚁样式模式时,在模式启动之前至少需要提及一个根目录,并且JDK的ClassLoader.getResources()方法中的限制。如果未提及根目录,则它仅从扩展目录的根中检索文件。
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.
这篇关于PathMatchingResourcePatternResolver(春季)用法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!