SpringBoot启动时报错:The bean 'dataSource', defined in BeanDefinition defined in class path resource
SpringBoot启动时报错:
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.
这个问题主要是由于springBoot跟SpringCloud版本包不兼容导致的,修改一下版本号,重新导入maven即可解决,附上一张SpringCloud官网的版本对照图,同学们可以根据对照图选择适合自己的包
Release Train | Boot Version |
---|---|
Hoxton | 2.2.x |
Greenwich | 2.1.x |
Finchley | 2.0.x |
Edgware | 1.5.x |
Dalston | 1.5.x |
由于我用的springBoot版本是2.2.6,所以选择了Cloud为Hoxton的版本包
springBoot版本:
<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.2.6.RELEASE</version> <relativePath/> <!-- lookup parent from repository --> </parent>
SpringCloud版本:
<dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-dependencies</artifactId> <version>Hoxton.SR4</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement>