之前運行好端端的項目,今天下午打開只是添加了一個文件之后 再運行都報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 Action: Consider the following: If you want an embedded database (H2, HSQL or Derby), please put it on the classpath. If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).這個錯誤意思是說我配置數據庫的問題,但是很明顯如果是配置問題就不會踩坑一直頭疼一下午了,報這個錯的人也都不會上這兒來。
最根本的問題是沒有加載我們的application文件,當時看了很多解決辦法,有讓在application.yml中設置不啟用默認配置的,有讓在pom文件中添加什么依賴的,還有讓在main方法添加注釋的,該試的都試了,甚至把我本來添加的文件刪除掉,恢復到下午打開的狀態去運行依舊報這個錯誤,最后我解決的辦法是在一個評論區看到的,出現這個問題先別急著去修改你的項目,你就試試把這個項目clean掉,即把target刪掉,之后再重新package一遍,再運行,看看問題會不會解決,我按照這個方法已解決,總結就是idea發神經