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ā)現(xiàn)問題
由于application.xml實在controller模塊下的,
結(jié)果發(fā)現(xiàn)pom.xml的配置里面有一條配置是這樣的
<packaging>pom</packaging>
由于這里配置錯了pom導(dǎo)致我讀取不到resources的配置文件,所以才會報錯。
3.改正
<packaging>war</packaging>
然后重新刷新maven,運行項目

總結(jié)
以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。
- SpringBoot中application.properties與application.yml區(qū)別小結(jié)
- SpringBoot中讀取application.properties配置文件的方法
- 解決SpringBoot加載application.properties配置文件的坑
- 解決springboot application.properties server.port配置問題
- SpringBoot application.yml和bootstrap.yml的區(qū)別
- springboot讀取application.yaml文件數(shù)據(jù)的方法
- SpringBoot中application.properties、application.yaml、application.yml區(qū)別
相關(guān)文章
IDEA如何使用spring-Initializr快速搭建SpringBoot
這篇文章主要介紹了IDEA如何使用spring-Initializr快速搭建SpringBoot問題,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教2024-05-05
Spring如何基于Proxy及cglib實現(xiàn)動態(tài)代理
這篇文章主要介紹了Spring如何基于Proxy及cglib實現(xiàn)動態(tài)代理,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考下2020-06-06
解決spring boot 1.5.4 配置多數(shù)據(jù)源的問題
下面小編就為大家?guī)硪黄鉀Qspring boot 1.5.4 配置多數(shù)據(jù)源的問題。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2017-06-06
淺析Java8新特性Lambda表達(dá)式和函數(shù)式接口
Lambda表達(dá)式理解為是 一段可以傳遞的代碼。最直觀的是使用Lambda表達(dá)式之后不用再寫大量的匿名內(nèi)部類,簡化代碼,提高了代碼的可讀性2017-08-08
java web開發(fā)中大量數(shù)據(jù)導(dǎo)出Excel超時(504)問題解決
開發(fā)測試時候?qū)霐?shù)據(jù)遇到大數(shù)據(jù)導(dǎo)入的問題,整理了下,需要的朋友可以參考下2017-04-04

