Guard for null BeanFactory in @ConditionalOnBean

See gh-2080