Closed
Description
When execute a Spring Boot Fat Jar,it's bootstrapped in AppClassLoader
, actually switch to LaunchedURLClassLoader
during refreshing application context.
As the parent of LaunchedURLClassLoader
is AppClassLoader
, it will lead resource in /META-INF/*
of executable-fat-jar to be loaded repeatedly when invoke LaunchedURLClassLoader.getResources
:
public Enumeration<URL> getResources(String name) throws IOException {
Objects.requireNonNull(name);
@SuppressWarnings("unchecked")
Enumeration<URL>[] tmp = (Enumeration<URL>[]) new Enumeration<?>[2];
if (parent != null) {
tmp[0] = parent.getResources(name);
} else {
tmp[0] = BootLoader.findResources(name);
}
tmp[1] = findResources(name);
return new CompoundEnumeration<>(tmp);
}
it leads our program failed to run!would you fix it?