PathMatchingResourcePatternResolver(春季)用法 [英] PathMatchingResourcePatternResolver (spring) Usage

查看:349
本文介绍了PathMatchingResourcePatternResolver(春季)用法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用:

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆