Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource 已解決

問題再現:

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

原因:

問題的中文意思就是說:無法配置DataSource:未指定'url'屬性,也無法配置嵌入數據源。

很明顯,問題原因就是在你的應用中沒有配置datasource的一些相關屬性。

因爲SpringBoot是自動配置的,在項目中的application.yml配置文件中可能缺少了數據庫相關的配置。

解決辦法:

  • 方法1

如果是自己初期搭建框架,還沒有考慮關聯數據庫,可以先排除掉SpringBoot自動裝配DataSource的操作,更省去了後面的一系列的問題。

在主類的請求頭上加上:@SpringBootApplication(exclude={DataSourceAutoConfiguration.class}) 即可:

  • 方法2

乖乖的在application.yml配置文件中將datasource相關屬性補充完整:

 

少俠請留步 ... ヾ(◍°∇°◍)ノ゙ ... 
歡迎點贊、評論、加關注,讓更多人看到學到賺到
更多精彩,請關注我的"今日頭條號":Java雲筆記

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章