Currently, the auto-configuration metadata that we generate to prevent loading a class if a "basic" condition does not match only applies to auto-configurations.
Using a simple AutoConfiguration
with @Import
to other configuration classes is a common pattern in Spring Boot. Unfortunately, such imported classes are loaded, even if a @ConditionalOnClass
on it doesn't match.
The idea is to research an option where such classes would be pre-processed as well. This might largely reduce the number of classes Spring Boot has to load on startup.
Comment From: snicoll
This requires a framework change, see https://github.com/spring-projects/spring-framework/issues/24175
Comment From: snicoll
There is a proposal in https://github.com/snicoll/spring-boot/commit/41ba6625cdcd4fca8d4287c15003ab4badc9b6f1 that is pending review.
Comment From: dreis2211
@snicoll Do you have numbers how many classes are excluded/filtered eagerly now in comparison to the old approach?
Comment From: snicoll
It depends what you have on your classpath. For instance, all the caching variants are now filtered eagerly (if you don't have a cache lib on your classpath).