Datasource bean injection failed, with startup error

springboot2.X+sharding-jdbc 3.0+mybatis 2.1.0

When PageHelper 1.3.0 was introduced, the project could not start

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

Description:

The bean 'dataSource', defined in class path resource [io/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:
1.
automatically configure the priority problem. Add the org.apache.shardingsphere package path in @ componetscan to improve the scanning priority and solve the problem
@ componentscan (value = {“io. Shardingsphere. *” and “your other package names”})

2. Automatic injection of data source is prohibited

@SpringBootApplication(exclude={DataSourceAutoConfiguration.class})

Manual injection
https://www.cnblogs.com/inbeijing/p/14419108.html

Read More: