Hi all, I had a following scenario which lead me to conclusion that there's a bug in how springboot handles those two annotations mentioned in the title. 1. Let's have an interface A 2. Let's create implementation B of interface A. 3. Let's create a Bean of A (return B) and annotate it with ConditionalOnMissingBean (just a default bean implementation for when the user does not define his own implementation, kind of like a fallback) 4. Let's create a RestController with annotation ConditionalOnBean(A) 5. Endpoint is not instantiated which I believe it should

Cheers

Comment From: mbhave

@FrancoCorleone The order that bean definitions are loaded is critical to @ConditionalOnBean and we don't recommend that you use it on regular configuration classes. See this section of the Javadoc:

The condition can only match the bean definitions that have been processed by the application context so far and, as such, it is strongly recommended to use this condition on auto-configuration classes only. If a candidate bean may be created by another auto-configuration, make sure that the one using this condition runs after.

If you've got any additional questions please ask them on gitter or stackoverflow.com.