Apply initializers and bean registrations before registering classes
Previously, classes were registered first which meant that their conditions were evaluated before any initializers and bean registrations were applied. This prevented the bean registrations and initializers from affecting the outcome of the condition evaluation. This commit inverts the ordering so that classes are not registerd, and therefore their conditions are not evaluated, until after the bean registrations and initializers have been applied. Closes gh-31280
This commit is contained in:
@@ -402,12 +402,12 @@ public abstract class AbstractApplicationContextRunner<SELF extends AbstractAppl
|
||||
((DefaultResourceLoader) context).setClassLoader(this.runnerConfiguration.classLoader);
|
||||
}
|
||||
this.runnerConfiguration.environmentProperties.applyTo(context);
|
||||
this.runnerConfiguration.beanRegistrations.forEach((registration) -> registration.apply(context));
|
||||
this.runnerConfiguration.initializers.forEach((initializer) -> initializer.initialize(context));
|
||||
Class<?>[] classes = Configurations.getClasses(this.runnerConfiguration.configurations);
|
||||
if (classes.length > 0) {
|
||||
((AnnotationConfigRegistry) context).register(classes);
|
||||
}
|
||||
this.runnerConfiguration.beanRegistrations.forEach((registration) -> registration.apply(context));
|
||||
this.runnerConfiguration.initializers.forEach((initializer) -> initializer.initialize(context));
|
||||
context.refresh();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user