|
|
|
@ -16,6 +16,7 @@
|
|
|
|
|
|
|
|
|
|
package org.springframework.boot;
|
|
|
|
|
|
|
|
|
|
import java.lang.StackWalker.StackFrame;
|
|
|
|
|
import java.time.Duration;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
@ -26,9 +27,11 @@ import java.util.LinkedHashSet;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.Objects;
|
|
|
|
|
import java.util.Optional;
|
|
|
|
|
import java.util.Properties;
|
|
|
|
|
import java.util.Set;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
import java.util.stream.Stream;
|
|
|
|
|
|
|
|
|
|
import org.apache.commons.logging.Log;
|
|
|
|
|
import org.apache.commons.logging.LogFactory;
|
|
|
|
@ -275,12 +278,15 @@ public class SpringApplication {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Class<?> deduceMainApplicationClass() {
|
|
|
|
|
return StackWalker.getInstance(StackWalker.Option.RETAIN_CLASS_REFERENCE)
|
|
|
|
|
.walk((s) -> s.filter(e -> Objects.equals(e.getMethodName(), "main")).findFirst()
|
|
|
|
|
.map(StackWalker.StackFrame::getDeclaringClass))
|
|
|
|
|
return StackWalker.getInstance(StackWalker.Option.RETAIN_CLASS_REFERENCE).walk(this::findMainClass)
|
|
|
|
|
.orElse(null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Optional<Class<?>> findMainClass(Stream<StackFrame> stack) {
|
|
|
|
|
return stack.filter((frame) -> Objects.equals(frame.getMethodName(), "main")).findFirst()
|
|
|
|
|
.map(StackWalker.StackFrame::getDeclaringClass);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Run the Spring application, creating and refreshing a new
|
|
|
|
|
* {@link ApplicationContext}.
|
|
|
|
|