Tag Archives: could not be registered….

[Solved] ShardingJDBC Error: The bean ‘dataSource’, defined in class path resource [org/apache/shardingsphere/shardingjdbc/spring/boot/SpringBootConfiguration.class], could not be registered.

Error message

This means that there is already a bean with the same name in springboot, and rewriting this bean is not allowed

***************************
APPLICATION FAILED TO START
***************************

Description:

The bean 'dataSource', defined in class path resource [org/apache/shardingsphere/shardingjdbc/spring/boot/SpringBootConfiguration.class], could not be registered. A bean with that name has already been defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class] and overriding is disabled.

Action:

Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true

Solution:

In application Add the following configuration in properties: it is allowed to rewrite duplicate beans and overwrite the previous bean

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

[Solved] Feign Error: ‘xx.FeignClientSpecification’, defined in null, could not be registered.

The reason is that one spring boot cannot allow two feign clients, which should be configured in application.yml

spring:

  main:
    allow-bean-definition-overriding: true

In addition, the settings for package scanning should be set correctly, otherwise an error will be reported if the feign client of the corresponding package is not found

[Solved] Feign Call Error: The bean ‘XXX.FeignClientSpecification’, defined in null, could not be registered….

Problem Description:

Two remote call classes are created, one is to call refund and the other is to call discount

But the two calling classes are the same microservice called

All called @feignclient (value = “XXX shop”)

How to solve it: the interfaces of the same service should not be written in multiple interface classes, but be placed in the same interface class to define calls