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官网的版本对照图,同学们可以根据对照图选择适合自己的包

Table 1. Release train Spring Boot compatibility
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版本:


   org.springframework.boot
   spring-boot-starter-parent
   2.2.6.RELEASE
    

SpringCloud版本:


   
      
         org.springframework.cloud
         spring-cloud-dependencies
         Hoxton.SR4
         pom
         import
      
   

你可能感兴趣的:(SpringBoot启动时报错:The bean 'dataSource', defined in BeanDefinition defined in class path resource)