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.

 

原因:

未配置數據庫配置。

解決方法:

解決方法1:啓動類聲明,排除自動注入數據源配置,即取消數據庫配置。

在對應的application 中加入 “

@SpringBootApplication(exclude= {DataSourceAutoConfiguration.class})

解決方法2:修改配置文件,加入數據庫配置

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

若com.mysql.cj.jdbc.Driver爆紅,則在pom中引入

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>6.0.6</version>
        </dependency>

發佈了21 篇原創文章 · 獲贊 2 · 訪問量 8萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章