Finding Resources with PathMatchingResourcePatternResolver and URLClassloader in JARs

Loading the files dynamically in Spring is simple, I’d change the approach to finding the files with extensions.

Try the following:

ClassLoader cl = this.getClass().getClassLoader(); 
ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(cl);
Resource[] resources = resolver.getResources("classpath*:/*.xml") ;
for (Resource resource: resources){
    logger.info(resource.getFilename());
}

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)