The bean' dataSource', defined in class path resource The specific error and solution are below

The purpose of this configuration item is that if a bean with the same name exists in the current project, the bean defined later will overwrite the bean defined first.

The error message shows that under the declaration org.apache.shardingsphere.shardingjdbc.spring.boot package
Insert image description here

An error occurs when the dataSource bean in SpringBootConfiguration is used. The reason is that a dataSource bean with the same name has been declared when the DruidDataSourceAutoConfigure class under the com.alibaba.druid.spring.boot.autoconfigure package is loaded.

Insert image description here

Insert image description here

What we need to use is the dataSource under the shardingjdbc package, so we need to configure the above properties so that the ones loaded later overwrite those loaded first.

Solution

Add configuration in application.yml

spring:  
  main:
    allow-bean-definition-overriding: true

Guess you like

Origin blog.csdn.net/weixin_45417754/article/details/129699221