国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

解決報錯 Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedded datasource c

這篇具有很好參考價值的文章主要介紹了解決報錯 Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedded datasource c。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點擊"舉報違法"按鈕提交疑問。

解決報錯 Failed to configure a DataSource: ‘url’ attribute is not specified and no embedded datasource could be configured.的三種辦法

一、問題描述

在初次完成項目的構(gòu)建后,啟動項目時出錯,提示信息“ Failed to configure a DataSource: ‘url’ attribute is not specified and no embedded datasource could be configured. ” ,這個異常很好理解,直接翻譯成中文,一看便知了 “ 配置數(shù)據(jù)源失敗:沒有指定’url’屬性,也不能配置嵌入式數(shù)據(jù)源。 ” ,具體的錯誤內(nèi)容如下圖:

解決報錯 Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedded datasource c,bug,SpringBoot,java,spring boot,spring,數(shù)據(jù)庫,url

二、問題的原因

導(dǎo)致這個問題的原因是因為,在 pom.xml 配置文件中,配置了數(shù)據(jù)連接技術(shù) spring-boot-starter-jdbc 包 ,在啟動配置文件時 ,Spring Boot 的自動裝配機制就會去配置文件中找,相關(guān)的數(shù)據(jù)庫的連接配置信息,如果找不到則拋出異常信息(具體源碼就不在這兒分析了,有興趣的可以自行去查看)。

加入的 JDBC 依賴包 , 如下圖:
解決報錯 Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedded datasource c,bug,SpringBoot,java,spring boot,spring,數(shù)據(jù)庫,url

三、解決辦法

解決辦法分為三種:

3.1 第一種解決辦法

如果先暫時使用不到數(shù)據(jù)庫連接,只是測試搭建的項目是否能正常啟動,可以先將該配置依賴項 spring-boot-starter-jdbc 注釋掉即可,選中該項配置按快捷鍵 “ Ctrl + Shift + / ” 即可。
解決報錯 Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedded datasource c,bug,SpringBoot,java,spring boot,spring,數(shù)據(jù)庫,url
運行成功
解決報錯 Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedded datasource c,bug,SpringBoot,java,spring boot,spring,數(shù)據(jù)庫,url

3.2 第二種解決辦法

在 SpringBoot 應(yīng)用程序啟動時,排除 jdbc 的自動裝配機制即可,在程序入口文件中新增配置注解 “ @SpringBootApplication(exclude= DataSourceAutoConfiguration.class ) ” ,如下圖:
解決報錯 Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedded datasource c,bug,SpringBoot,java,spring boot,spring,數(shù)據(jù)庫,url
運行成功
解決報錯 Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedded datasource c,bug,SpringBoot,java,spring boot,spring,數(shù)據(jù)庫,url

3.3 第三種解決辦法:

在開發(fā)庫或者本地庫中,如果有可用的臨時數(shù)據(jù)庫,可以先配置該庫為暫時的數(shù)據(jù)庫即可,在 application.yml 配置文件中,加入如下圖配置內(nèi)容:
解決報錯 Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedded datasource c,bug,SpringBoot,java,spring boot,spring,數(shù)據(jù)庫,url
修改配置后,測試是否能正常啟動,如下圖:
解決報錯 Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedded datasource c,bug,SpringBoot,java,spring boot,spring,數(shù)據(jù)庫,url
好了,關(guān)于 Failed to configure a DataSource: ‘url’ attribute is not specified and no embedded datasource 的解決辦法 就寫到這兒了,如果還有什么疑問或遇到什么問題歡迎提問,也可以給我私信留言哦,我會一一詳細(xì)解答的。
歇后語:“ 共同學(xué)習(xí),共同進(jìn)步 ”,也希望大家多多關(guān)注CSND的IT社區(qū)。文章來源地址http://www.zghlxwxcb.cn/news/detail-719142.html

到了這里,關(guān)于解決報錯 Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedded datasource c的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實不符,請點擊違法舉報進(jìn)行投訴反饋,一經(jīng)查實,立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費用

相關(guān)文章

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包