mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-10-02 07:19:01 +00:00
Allow Devtools Restarter to work with a parameterless main method
See gh-47987 Signed-off-by: Dmytro Nosan <dimanosan@gmail.com>
This commit is contained in:
committed by
Stéphane Nicoll
parent
b9216a05e6
commit
bf0152e67c
+10
-1
@@ -60,7 +60,7 @@ class MainMethod {
|
||||
private Method getMainMethod(StackTraceElement element) {
|
||||
try {
|
||||
Class<?> elementClass = Class.forName(element.getClassName());
|
||||
Method method = elementClass.getDeclaredMethod("main", String[].class);
|
||||
Method method = getMainMethod(elementClass);
|
||||
if (Modifier.isStatic(method.getModifiers())) {
|
||||
return method;
|
||||
}
|
||||
@@ -71,6 +71,15 @@ class MainMethod {
|
||||
return null;
|
||||
}
|
||||
|
||||
private static Method getMainMethod(Class<?> clazz) throws Exception {
|
||||
try {
|
||||
return clazz.getDeclaredMethod("main", String[].class);
|
||||
}
|
||||
catch (NoSuchMethodException ex) {
|
||||
return clazz.getDeclaredMethod("main");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the actual main method.
|
||||
* @return the main method
|
||||
|
||||
Reference in New Issue
Block a user