-
Notifications
You must be signed in to change notification settings - Fork 41.7k
Closed
Milestone
Description
Hi,
I'm using spring boot 1.3.0.RELEASE and using PathMatchingResourcePatternResolver to find mybatis mapper files with under code:
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
sessionFactoryBean.setMapperLocations(resolver.getResources("classpath*:mybatis*/**/*Mapper.xml"));It works fine under 1.3.0.RELEASE. For some reason I upgrade spring boot to 1.4.0.RELEASE, then it can not work.
I debug into the source ,find the code in PathMatchingResourcePatternResolver:
protected Set<Resource> doFindAllClassPathResources(String path) throws IOException {
Set<Resource> result = new LinkedHashSet<Resource>(16);
ClassLoader cl = getClassLoader();
Enumeration<URL> resourceUrls = (cl != null ? cl.getResources(path) : ClassLoader.getSystemResources(path));
while (resourceUrls.hasMoreElements()) {
URL url = resourceUrls.nextElement();
result.add(convertClassLoaderURL(url));
}
if ("".equals(path)) {
// The above result is likely to be incomplete, i.e. only containing file system references.
// We need to have pointers to each of the jar files on the classpath as well...
addAllClassLoaderJarRoots(cl, result);
}
return result;
}The different between 1.4.0 and 1.3.0, the 'resourceUrls.hasMoreElements()' returned false and true.It seems that 'cl.getResources(path)' returned different object.
So, why this happened and how to resolve it?