具体遇到的错误:
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
一开始从网上搜查,在配置文件里加了该配置,问题没有解决。
spring.main.allow-bean-definition-overriding=true
启动类加
(exclude = {org.springframework.boot.autoconfigure.jdbc.DataSourceConfiguration.class})
引起空指针异常。
后来以为是jar包冲突,对jar进行排查,未发现问题。
最后发现是配置文件缺少properties尾缀的原因。