Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PathMatchingResourcePatternResolver (spring) Usage

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 ?

like image 932
Marc Polizzi Avatar asked Jun 15 '12 09:06

Marc Polizzi


1 Answers

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.

like image 187
Ravi Kadaboina Avatar answered Oct 16 '22 08:10

Ravi Kadaboina