欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

Springboot啟動(dòng)提示數(shù)據(jù)源錯(cuò)誤怎么辦

這篇文章主要介紹了Spring boot 啟動(dòng)提示數(shù)據(jù)源錯(cuò)誤怎么辦,具有一定借鑒價(jià)值,感興趣的朋友可以參考下,希望大家閱讀完這篇文章之后大有收獲,下面讓小編帶著大家一起了解一下。

創(chuàng)新互聯(lián)于2013年成立,先為沈北新等服務(wù)建站,沈北新等地企業(yè),進(jìn)行企業(yè)商務(wù)咨詢服務(wù)。為沈北新企業(yè)網(wǎng)站制作PC+手機(jī)+微官網(wǎng)三網(wǎng)同步一站式服務(wù)解決您的所有建站問題。

在啟動(dòng) Spring Boot 的項(xiàng)目的時(shí)候提示數(shù)據(jù)源未配置的錯(cuò)誤。

09:52:08.333 [main] DEBUG o.s.b.d.LoggingFailureAnalysisReporter - Application failed to start due to an exceptionorg.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Failed to determine a suitable driver classat org.springframework.boot.autoconfigure.jdbc.DataSourceProperties.determineDriverClassName(DataSourceProperties.java:233)	at org.springframework.boot.autoconfigure.jdbc.DataSourceProperties.initializeDataSourceBuilder(DataSourceProperties.java:174)

Spring 會(huì)提示你完整的導(dǎo)致啟動(dòng)錯(cuò)誤的信息是:

***************************
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).Process finished with exit code 1

錯(cuò)誤分析

從上面的啟動(dòng)信息來看,已經(jīng)說得非常清楚了,就是因?yàn)槟闩渲昧?Spring 的數(shù)據(jù)組件,但是你沒有配置相應(yīng)的數(shù)據(jù)源。

因?yàn)檫@個(gè)會(huì)導(dǎo)致你的啟動(dòng)失敗。

解決辦法

有下面的集中解決辦法:

加入 H2 包

最簡(jiǎn)單的解決辦法就是在依賴中添加 H2 的數(shù)據(jù)庫,如果你使用 Spring Batch 的話,這個(gè)組件也是需要的,因?yàn)?Spring 會(huì)使用 H2 為數(shù)據(jù)源。

添加數(shù)據(jù)源配置

如果你已經(jīng)添加了數(shù)據(jù)庫驅(qū)動(dòng),例如你添加了 MySQL 的數(shù)據(jù)庫驅(qū)動(dòng)。

那么你需要制定 Mysql 的數(shù)據(jù)庫連接參數(shù)。

spring.datasource.url=jdbc:mysql://localhost:3306/myDbspring.datasource.username=user1spring.datasource.password=passspring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver

在啟動(dòng)時(shí)候不載入數(shù)據(jù)源配置。

你可用在啟動(dòng)的時(shí)候不載入數(shù)據(jù)源配置。

可用在啟動(dòng)類上面,添加下面的注解。

@SpringBootApplication(exclude={DataSourceAutoConfiguration.class})

Spring boot 啟動(dòng)提示數(shù)據(jù)源錯(cuò)誤怎么辦

你也可以在啟動(dòng)配置文件上面,添加下面的內(nèi)容,這樣能夠保證你在啟動(dòng)的時(shí)候不載入數(shù)據(jù)源配置類。

spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.jdbc.DataSourceAuto

感謝你能夠認(rèn)真閱讀完這篇文章,希望小編分享的“Spring boot 啟動(dòng)提示數(shù)據(jù)源錯(cuò)誤怎么辦”這篇文章對(duì)大家有幫助,同時(shí)也希望大家多多支持創(chuàng)新互聯(lián),關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,更多相關(guān)知識(shí)等著你來學(xué)習(xí)!

標(biāo)題名稱:Springboot啟動(dòng)提示數(shù)據(jù)源錯(cuò)誤怎么辦
文章鏈接:http://www.chinadenli.net/article0/pgcoio.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供商城網(wǎng)站企業(yè)網(wǎng)站制作網(wǎng)站設(shè)計(jì)電子商務(wù)ChatGPT關(guān)鍵詞優(yōu)化

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

網(wǎng)站建設(shè)網(wǎng)站維護(hù)公司