SpringBoot項目剛剛創建就報異常,Failed to configure a DataSource: 'url' attribute is not specified and no embedded 的解決辦法


錯誤信息:

Description:

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

Reason: Failed to determine a suitable driver class

 

直接翻譯成中文,一看便知了 “ 配置數據源失敗:沒有指定’url’屬性,也不能配置嵌入式數據源。 ” 

 

解決的辦法:

   先導入依賴試試:

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>

如果不行,那就執行下一步:
在主啟動類的注解加上這個 exclude=DataSourceAutoConfiguration.class

 

如果不行,就配上 數據庫的信息

spring.datasource.driver-class-name = com.mysql.jdbc.Driver
spring.datasource.url = jdbc:mysql://localhost:3306/mybatis?useUnicode=true&characterEncoding=utf8&useSSL=false
spring.datasource.username = root
spring.datasource.password = 123456

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM