-
Notifications
You must be signed in to change notification settings - Fork 41.2k
Canceled @ConditionalOnMissingBean now also checks beans available via BeanFactory #352
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I think you mean "when we have a In short, I don't think we can do anything with this pull request. But please try to change your |
I'm using provided |
I guess Anyway, |
Hmmm - can you take a look at my test? It shows where the problem is and fails in current code |
I included your test case ( |
I meant I know that using The whole problem is that when you don't want to allow eager initialization (which of course if great) then you have to get generic type of |
Look again. The one that is |
Ok - now I see. But I still think that this is a bug |
If every slightly surprising thing about Spring is a bug, then I guess you must be right. Maybe you could open an issue in the SPR JIRA highlighting the XML/Java conflict. There are other issues with |
Ok, if you want we can close this PR, but I think the problem is deeper. For example using such configuration
causes flickering test due to random order of beans initialization. Of course it could be just my incorrect approach to testing but I don't know if such situation won't happen in real application. If it's only applicable to beans in single EDIT: In fact I've just solved that issue without instantiating |
In response to spring-projectsgh-352
Currently when we've BeanFactory in our configuration and bean annotated with @ConditionalOnMissingBean both are created (ExampleBeanAndFactoryBeanConfiguration). This causes problem with autowiring/getting bean by type - NoUniqueBeanDefinitionException is thrown.
I've added support for such situation (it happens in our project - we've got MongoBeanFactory and MongoAutoConfiguration contains @bean returning Mongo instance.
In fact it's quite big change and causes problems, which I cannot overcome (for example with getting BeanFactory return type without initialization - to prevent eager loading).
Any comments/ideas are welcomed :)