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
之前啓動是正常的,出差之後還沒動這個項目,突然之間啓動不起來,按照翻譯的情況,就是找不到數據庫相關的配置,但是健康度檢查項目是從配置文件中讀出相關內容,爲啥會沒有數據庫相關配置?
(1)查配置服務:
如果用如下url:
http://localhost:8081/order-a.yml
是能正常訪問到相關的配置文件,但是如果要訪問healch-check的配置文件:
採用如下url:、
http://localhost:8081/health-check-dev.yml
http://localhost:8081/health-check-proc.yml
http://localhost:8081/health-check.yml
值均爲:{}
說明很可能就是config服務的問題,說明很可能是沒有更新或者有其他情況,我先進行更新試試:
http://localhost:8081/actuator/bus-refresh
這個注意,8081對應的是配置中心服務,而且要發出post請求,然後發現確實是有值的。
(2)查看日誌
重新啓動服務,發現還是報這個錯。沒有找到相關數據庫配置,那麼有沒有可能還是這個問題,只是沒有找到。重啓了這個服務,然後仔細看了看日誌:
2019-09-19 15:29:40.762 WARN 49376 --- [ main] c.c.c.ConfigServicePropertySourceLocator : Could not locate PropertySource: {"timestamp":"2019-09-19T07:29:29.189+0000","status":500,"error":"Internal Server Error","message":"Cannot load environment","path":"/health-check/test"}
2019-09-19 15:29:40.762 INFO 49376 --- [ main] c.u.healthcheck.HealthCheckApplication : No active profile set, falling back to default profiles: default
果然是沒有拉下配置!Could not locate PropertySource的意思就是沒有spring cloud的配置。爲什麼沒有找到呢?
訪問服務器上的配置服務:
http://165host:8081/health-check.yml
果然返回結果爲空。目前定位了問題在於config服務的問題!
(3)查看config運行情況
重啓了config服務之後果然就沒有問題了,事後再查查日誌看下是什麼原因造成的。
總結:首先定位問題,然後嘗試各種可能的解決方案,最後根據問題再去推測整套框架的運行機制。