Ensure ContextRunner class can be loaded

Even if FunctionalSpringApplication is not available.
This commit is contained in:
Dave Syer
2018-11-12 12:02:55 +00:00
parent 10f446d6b5
commit 9c6c7d09d4

View File

@@ -121,14 +121,13 @@ public class ContextRunner {
return this.error;
}
private static SpringApplication builder(Class<?> type,
StandardEnvironment environment) {
private SpringApplication builder(Class<?> type, StandardEnvironment environment) {
SpringApplication application;
if (!isFunctional(environment)) {
application = new SpringApplication(type);
}
else {
application = new FunctionalSpringApplication(type);
application = FunctionalSpringApplicationCreator.create(type);
}
application.setEnvironment(environment);
application.setRegisterShutdownHook(false);
@@ -144,4 +143,12 @@ public class ContextRunner {
return environment.resolvePlaceholders("${spring.functional.enabled:true}")
.equals("true");
}
private static class FunctionalSpringApplicationCreator {
public static SpringApplication create(Class<?> type) {
return new FunctionalSpringApplication(type);
}
}
}