Description
Dave Syer opened SPR-17206 and commented
There is a lot of evidence that ConfigurationClassPostProcessor
is bad for startup time. There is also some evidence that part of the problem is lite bean configuration - we have to scan all methods of all bean definition classes looking for @Bean
. To investigate this I made a version of ConfigurationClassPostProcessor
that only uses classes from spring.components
. It is much faster when there are no @Configuration
classes.
The rationale for introducing lite beans was IIRC so that you wouldn't pay the cost of CGLib proxying. But that is so much faster now than it was when we invented @Configuration
I don't believe it adds up any more - the cost of processing annotations is much higher. And we have to recursively search all nested classes of all bean definitions. Ugh.
If lite beans were optional, Spring Boot could switch them off, and we can flush out all the usages (which are probably mostly accidental at this point).
Affects: 5.0.8
Issue Links:
- JUnit Jupiter @Nested class cannot share enclosing class's ApplicationContext if nested class is deemed to be a configuration candidate [SPR-16595] #21136 JUnit Jupiter
@Nested
class cannot share enclosing class's ApplicationContext if nested class is deemed to be a configuration candidate - Java 10: "Illegal method name" when test functions in Kotlin contain spaces in name [SPR-17137] #21674 Java 10: "Illegal method name" when test functions in Kotlin contain spaces in name
- Spring internal configuration classes can no longer use @EventListener [SPR-17160] #19660 Spring internal configuration classes can no longer use
@EventListener
- Do not consider all @Component instances as @Configuration candidates [SPR-10609] #15238 Do not consider all
@Component
instances as@Configuration
candidates - Automatically detect and register nested @Configuration classes [SPR-8186] #12837 Automatically detect and register nested
@Configuration
classes - Consider @Import classes as lite @Configuration [SPR-10533] #15163 Consider
@Import
classes as lite@Configuration
- A lite configuration class's member classes are processed when it's imported but not when it's registered directly [SPR-16839] #21379 A lite configuration class's member classes are processed when it's imported but not when it's registered directly
- @ComponentScan should get processed without @Configuration as well [SPR-11769] #16391
@ComponentScan
should get processed without@Configuration
as well - Add bean definition attribute for ConfigurationClassPostProcessor to skip "lite" bean detection [SPR-17412] #21945 Add bean definition attribute for ConfigurationClassPostProcessor to skip "lite" bean detection
2 votes, 8 watchers