A bean with that name has already been defined in DataSourceConfiguration$Hikari.class

问题:

启动SpringBoot项目报错:

***************************
APPLICATION FAILED TO START
***************************
Description:

The bean 'dataSource', defined in BeanDefinition defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.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

原因:

SpringBoot和SpringCloud的版本不兼容造成。
这里因为SpringBoot想尝鲜使用了2.1.0,而SpringCloud仍然用的是Finchley.SR2,而它支持的是2.0.x及以下版本。
对应的版本应该使用Greenwich.M1
Issues回答:
A bean with that name has already been defined in DataSourceConfiguration$Hikari.class_第1张图片
A bean with that name has already been defined in DataSourceConfiguration$Hikari.class_第2张图片

解决:

降SpringBoot版本或者使用Greenwich.M1
所以还是建议直接在start.spring.io上构建新项目,或者在idea上构建项目的时候选择Spring Initializr来避免版本不兼容。

你可能感兴趣的:(错误集)