SpringBoot沒有讀取到application.yml問題及解決
1.遇到的問題
***************************
APPLICATION FAILED TO START
***************************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
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.yml文件配置的一點問題都沒有,依賴也依賴夠了,可是還是報這個錯。
2.發(fā)現問題
由于application.xml實在controller模塊下的,
結果發(fā)現pom.xml的配置里面有一條配置是這樣的
<packaging>pom</packaging>
由于這里配置錯了pom導致我讀取不到resources的配置文件,所以才會報錯。
3.改正
<packaging>war</packaging>
然后重新刷新maven,運行項目

總結
以上為個人經驗,希望能給大家一個參考,也希望大家多多支持腳本之家。
- SpringBoot中application.properties與application.yml區(qū)別小結
- SpringBoot中讀取application.properties配置文件的方法
- 解決SpringBoot加載application.properties配置文件的坑
- 解決springboot application.properties server.port配置問題
- SpringBoot application.yml和bootstrap.yml的區(qū)別
- springboot讀取application.yaml文件數據的方法
- SpringBoot中application.properties、application.yaml、application.yml區(qū)別
相關文章
IDEA如何使用spring-Initializr快速搭建SpringBoot
這篇文章主要介紹了IDEA如何使用spring-Initializr快速搭建SpringBoot問題,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教2024-05-05
Spring如何基于Proxy及cglib實現動態(tài)代理
這篇文章主要介紹了Spring如何基于Proxy及cglib實現動態(tài)代理,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友可以參考下2020-06-06
java web開發(fā)中大量數據導出Excel超時(504)問題解決
開發(fā)測試時候導入數據遇到大數據導入的問題,整理了下,需要的朋友可以參考下2017-04-04

