private Class<?> deduceMainApplicationClass() {
try {
StackTraceElement[] stackTrace = new RuntimeException().getStackTrace();
for (StackTraceElement stackTraceElement : stackTrace) {
if ("main".equals(stackTraceElement.getMethodName())) {
return Class.forName(stackTraceElement.getClassName());
}
}
}
catch (ClassNotFoundException ex) {
// Swallow and continue
}
return null;
}
これはSpringApplicationは、メインクラスのメソッドを取得しています。常に^ _ ^、春にはまた、他のより良い方法がないかわからないので、使用し期待していなかった、このようビット「後退」と感じました。