Polish "Report friendly error when failing to find AOT initializer"
See gh-38188
This commit is contained in:
parent
8126d2652d
commit
e3210e72d5
|
@ -437,12 +437,10 @@ public class SpringApplication {
|
|||
initializers.stream().filter(AotApplicationContextInitializer.class::isInstance).toList());
|
||||
if (aotInitializers.isEmpty()) {
|
||||
String initializerClassName = this.mainApplicationClass.getName() + "__ApplicationContextInitializer";
|
||||
if (!ClassUtils.isPresent(initializerClassName, getClassLoader())) {
|
||||
throw new IllegalArgumentException(
|
||||
"You are starting application with AOT mode but not AOT-processed,"
|
||||
+ " please build your application with AOT first."
|
||||
+ " Or remove system property 'spring.aot.enabled=true' to run as regular mode.");
|
||||
}
|
||||
Assert.state(ClassUtils.isPresent(initializerClassName, getClassLoader()),
|
||||
"You are starting the application with AOT mode enabled but AOT processing hasn't happened. "
|
||||
+ "Please build your application with enabled AOT processing first, "
|
||||
+ "or remove the system property 'spring.aot.enabled' to run the application in regular mode");
|
||||
aotInitializers.add(AotApplicationContextInitializer.forInitializerClasses(initializerClassName));
|
||||
}
|
||||
initializers.removeAll(aotInitializers);
|
||||
|
|
|
@ -1383,8 +1383,8 @@ class SpringApplicationTests {
|
|||
application.setMainApplicationClass(TestSpringApplication.class);
|
||||
System.setProperty(AotDetector.AOT_ENABLED, "true");
|
||||
try {
|
||||
assertThatIllegalArgumentException().isThrownBy(application::run)
|
||||
.withMessageContaining(AotDetector.AOT_ENABLED);
|
||||
assertThatIllegalStateException().isThrownBy(application::run)
|
||||
.withMessageContaining("but AOT processing hasn't happened");
|
||||
}
|
||||
finally {
|
||||
System.clearProperty(AotDetector.AOT_ENABLED);
|
||||
|
|
Loading…
Reference in New Issue