Brief description
@ConditionalOnClass not work as expected when added in AllNestedConditions.
Reproduce sample
- Link to reproduce sample: https://github.com/rujche/problem-reproduce/tree/ConditionalOnClass-not-work-as-expected-when-added-in-AllNestedConditions
- Please read the README.md to get more information.
Comment From: wilkinsona
This due to a few mistakes in your configuration. I've forked the sample and pushed a commit with comments describing the changes that need to be made and why.
Comment From: rujche
Hi, @wilkinsona
Thank you for your quick response and detailed explanation. ~2 points still confused me:~ (Problem solved.)
~1. As I commented in your commit, I didn't understand why all of the nested conditions use the parse configuration phase.
2. When using @Import annotation, @ConditionalOnClass and AllNestedConditions have same behavior. But when using META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports, they behave different. I updated the sample project, please take a look: https://github.com/rujche/problem-reproduce/tree/ConditionalOnClass-not-work-as-expected-when-added-in-AllNestedConditions~
Comment From: rujche
Hi, @wilkinsona
Thank you for your quick response and detailed explanation. 2 points still confused me:
- As I commented in your commit, I didn't understand why
all of the nested conditions use the parse configuration phase.- When using
@Importannotation, @ConditionalOnClass and AllNestedConditions have same behavior. But when usingMETA-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports, they behave different. I updated the sample project, please take a look: https://github.com/rujche/problem-reproduce/tree/ConditionalOnClass-not-work-as-expected-when-added-in-AllNestedConditions
Update: 1. About point 1, I already got the answer. 2. About point 2, I updated the sample to Use PARSE_CONFIGURATION to make FirstAutoConfiguration and SecondAutoConfiguration have same behavior. Thank you all the same.