Marc Polizzi
Marc Polizzi

Reputation: 9375

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 ?

Upvotes: 9

Views: 7360

Answers (1)

Ravi Kadaboina
Ravi Kadaboina

Reputation: 8574

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.

Upvotes: 9

Related Questions