20

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.

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
Justin Miller
  • 757
  • 2
  • 8
  • 19
  • Do you have any special reason that would make the order of conditional evaluations relevant? – geoand Jul 06 '14 at 14:49
  • 2
    No, you're right. Looking at my case again, the order is not important, so long as the behavior that Dave describes below is accurate, that should be fine for me. – Justin Miller Jul 06 '14 at 17:44

1 Answers1

25

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.

Dave Syer
  • 56,583
  • 10
  • 155
  • 143