DataSource bean overriding in spring boot 2.1

Adding following Property in application.properties would solve the issue .

spring.main.allow-bean-definition-overriding=true

Further one might have to add another property to resolve another issue mentioned : https://github.com/openzipkin/zipkin/issues/2043

management.metrics.web.server.auto-time-requests=false


I ran into a similar problem and it is very generic (sometimes there are duplicated annotation sometimes duplicated beans). In case when you have duplicated annotation like @EnableJpaRepository the error message not mention this annotation at all. The best way to find where the problem is:

Open class DefaultListableBeanFactory There should be code like this:

BeanDefinition existingDefinition = (BeanDefinition)this.beanDefinitionMap.get(beanName);
        if (existingDefinition != null) {
            if (!this.isAllowBeanDefinitionOverriding()) {
                throw new BeanDefinitionOverrideException(beanName, beanDefinition, existingDefinition);
            }

Put a breakpoint in line with throw new. Then existingDefinition.source.className is pointing to configuration which is already registered and here is the problem. When you check the beanDefinition.source.className you will compare both classes and find where duplicated code or annotation is, just delete/fix them.


I ran into a similar problem with this today and the following spring cloud config issue helped me: Issue 1142.

We were using Spring Cloud Config which is not compatible with Spring Boot 2.1.0 as of yet. The Greenwich release train of Spring Cloud will be compatible with Spring Boot 2.1.0.

Your @EnableCircuitBreaker annotation leads me to believe you might also be using a version of Spring Cloud that is not compatible with the 2.1.0 release of Spring Boot.