diff --git a/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/LaunchedURLClassLoader.java b/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/LaunchedURLClassLoader.java index ba12d25755..fa2de4e260 100644 --- a/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/LaunchedURLClassLoader.java +++ b/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/LaunchedURLClassLoader.java @@ -21,6 +21,7 @@ import java.net.URL; import java.net.URLClassLoader; import java.security.AccessController; import java.security.PrivilegedExceptionAction; +import java.util.Enumeration; import org.springframework.boot.loader.jar.RandomAccessJarFile; @@ -53,6 +54,43 @@ public class LaunchedURLClassLoader extends URLClassLoader { return null; } + @Override + public URL getResource(String name) { + URL url = null; + if (this.rootClassLoader != null) { + url = this.rootClassLoader.getResource(name); + } + return (url == null ? findResource(name) : url); + } + + @Override + public Enumeration getResources(String name) throws IOException { + + if (this.rootClassLoader == null) { + return findResources(name); + } + + final Enumeration rootResources = this.rootClassLoader.getResources(name); + final Enumeration localResources = findResources(name); + + return new Enumeration() { + + @Override + public boolean hasMoreElements() { + return rootResources.hasMoreElements() + || localResources.hasMoreElements(); + } + + @Override + public URL nextElement() { + if (rootResources.hasMoreElements()) { + return rootResources.nextElement(); + } + return localResources.nextElement(); + } + }; + } + /** * Attempt to load classes from the URLs before delegating to the parent loader. */