I want to make my spring-boot configuration class A dependent on another configuration class B, i.e. A configuration is evaluated only if B configuration is evaluated.
In the real context, I have hundreds of Ai configurations and only one B, and I want to implement a way to exclude all the Ai configs by excluding only B during tests.
I tried the following:
@Configuration
@ConditionalOnBean(type = "org.my.B")
public class A1AutoConfiguration {
// ...
}
Where B is a unconditioned configuration class.
But when I run mvn spring-boot:run -Ddebug=true I see that A is never evaluated because B is missing. While the beans created inside B are in the application context, B itself is not.
I though I can make the Ai configuration classes dependent on beans created inside B but I don't like so much this solution.
Is there a cleaner (and working) way to implement such a dependency mechanism?