Spring Boot 报错:Failed to configure a DataSource:Failed to configure a DataSource:

搭建Spring Boot时报错

Description:

Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.

Spring Boot 报错:Failed to configure a DataSource:Failed to configure a DataSource:_第1张图片

 

原因:

未配置数据库配置。

解决方法:

解决方法1:启动类声明,排除自动注入数据源配置,即取消数据库配置。

在对应的application 中加入 “

@SpringBootApplication(exclude= {DataSourceAutoConfiguration.class})

Spring Boot 报错:Failed to configure a DataSource:Failed to configure a DataSource:_第2张图片

解决方法2:修改配置文件,加入数据库配置

spring:
  datasource:
    driver-class-name: com.mysql.cj.jdbc.Driver
    url: jdbc:mysql:
    username: 
    password: 

Spring Boot 报错:Failed to configure a DataSource:Failed to configure a DataSource:_第3张图片

若com.mysql.cj.jdbc.Driver爆红,则在pom中引入

        
            mysql
            mysql-connector-java
            6.0.6
        

Spring Boot 报错:Failed to configure a DataSource:Failed to configure a DataSource:_第4张图片

你可能感兴趣的:(Spring,Boot,java,报错)