I have two beans with same name in two different third-party libraries. Getting an exception that bean with the name ‘dataSource’ already registered and overriding is disabled.
//jar-A
public class DataConfiguration {
@Bean
@ConditionalOnMissingBean(value = {AbstractDataSource.class})
public DataBundleItemSource dataSource() {
//code goes here
}
//jar-B
public class UserConfiguration {
@Bean
public InventoryItemSource dataSource() {
//code goes here
}
We can’t enable bean override at application level, as we never know which ben overridden in future.
Excluding the class at application level is not feasible as there are other properties and functions being used across application level from both classes.
We also tried to override the bean from jar-A, but no luck.
Is there any other way to not register the dataSource bean from jar-A ?
Appreciate help.