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
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.
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