Search code examples
springspring-bootspring-annotations

Can you specify multiple @Conditional annotations?


With Spring Boot, can one use multiple @Conditional annotations on one @Bean definition? If so, is there a predictable order that they are resolved? In other words, can I specify both @ConditionalOnResource and @ConditionalOnMissingBean on the same @Bean def? Which one would take precedence?

I'm using Spring Boot 1.0.2.RELEASE.


Solution

  • I don't think the order is important: any Condition that doesn't match will cause the bean to be omitted. If they all match, it will be included.