Problem brief description
When @EnableConfigurationProperties added in parent class, it didn't work as expected in some corner case.
Reproduce the problem
- Here is the sample project to reproduce this problem: https://github.com/rujche/problem-reproduce/tree/EnableConfigurationProperties-not-work-well-when-added-in-parent-class .
- Please read README.md in the sample project to get more information.
Comment From: wilkinsona
Thanks for the sample.
The behavior that you are seeing is due to Spring Framework's ConfigurationClassParser
. It processes AutoConfigurationOne
and AutoConfigurationBase
but they are skipped because the @ConditionalOnBean
on AutoConfigurationOne
does not match. This processing adds AutoConfigurationBase
to the map of known super-classes. Next it processes AutoConfigurationTwo
and AutoConfigurationBase
. AutoConfigurationBase
is skipped again as it's already present in the map of known super-classes even though its sub-class has different conditions this time.
Changing this behavior will require a change in Spring Framework as it's out of Spring Boot's control. We'll transfer this issue so that the Framework team can take a look.
Comment From: jhoeller
This looks like a variant of #28676 which should be fixed in the 6.2 milestones already. Yet another case of "does this work when running against 6.2.0-M4" :-)
Comment From: wilkinsona
I thought the problem rang a bell and #28676 explains why. Thanks for the link.
All of the tests in the provided sample pass when Framework's upgraded to 6.2.0-M4.
Comment From: jhoeller
Thanks for the check, Andy. I'll close this issue as a duplicate then.
Comment From: rujche
@wilkinsona , @jhoeller
Thank you for your quick response. Now it's OK to close this issue.