Reputation: 16982
I have multiple datasource beans defined in my configuration file.I have 2 beans named customerDataSource. I want one of them to be instantiated only if other bean is not loaded.I was trying to use @ConditionalOnMissingBean. However it looks like this will work only when another bean of same "type" is not present. Is there a way to control this by using "name"?
Upvotes: 4
Views: 6825
Reputation: 44515
The annotation has the parameter name, where you can specify the bean name that should be checked:
@ConditionalOnMissingBean(name = "beanNameToCheck")
Upvotes: 10