SpringBoot啟動報錯Failed to determine a suitable driver class
SpringBoot啟動報錯如下
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-05-06 21:27:18.275 ERROR 10968 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :***************************
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

把這個依賴注釋掉就好了

原因
應(yīng)用沒有使用到DataSource,但是在pom.xml里引入了mybatis-spring-boot-starter
問題解決辦法
有兩種:
把mybatis-spring-boot-starter的依賴去掉,這樣就不會觸發(fā)spring boot相關(guān)的代碼
把spring boot自動初始化DataSource相關(guān)的代碼禁止掉
禁止的辦法有兩種:
在啟動類的@SpringBootApplication加上
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class, DataSourceTransactionManagerAutoConfiguration.class })
在application.properties里配置:
spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration,org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
java.math.BigDecimal的用法及加減乘除計算
這篇文章主要介紹了java.math.BigDecimal的用法及加減乘除計算,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2023-05-05
java實現(xiàn)String字符串處理各種類型轉(zhuǎn)換
在日常的程序開發(fā)中,經(jīng)常會涉及到不同類型之間的轉(zhuǎn)換,本文主要介紹了String字符串處理各種類型轉(zhuǎn)換,具有一定的參考價值,感興趣的可以了解一下2023-10-10
Spring?MVC中的Controller進行單元測試的實現(xiàn)
本文主要介紹了如何對Spring?MVC中的Controller進行單元測試的實現(xiàn),文中通過示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下2022-02-02
sentinel?整合spring?cloud限流的過程解析
這篇文章主要介紹了sentinel?整合spring?cloud限流,本文通過實例代碼給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下2022-03-03
Java經(jīng)典算法匯總之選擇排序(SelectionSort)
選擇排序也是比較簡單的一種排序方法,原理也比較容易理解,選擇排序在每次遍歷過程中只記錄下來最小的一個元素的下標(biāo),待全部比較結(jié)束之后,將最小的元素與未排序的那部分序列的最前面一個元素交換,這樣就降低了交換的次數(shù),提高了排序效率。2016-04-04

