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)文章
SpringBoot整合Mybatis-plus實現(xiàn)多級評論功能
本文介紹了如何使用SpringBoot整合Mybatis-plus實現(xiàn)多級評論功能,同時提供了數(shù)據(jù)庫的設(shè)計和詳細的后端代碼,前端界面使用的Vue2,本文通過實例代碼給大家介紹的非常詳細,對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友參考下吧2023-05-05SpringBoot任務(wù)之定時任務(wù)相關(guān)知識總結(jié)
今天給大家整理的文章是SpringBoot定時任務(wù)的相關(guān)知識點,文中有非常詳細的介紹及代碼示例,對正在學(xué)習(xí)SpringBoot任務(wù)的小伙伴們很有幫助,需要的朋友可以參考下2021-06-06SpringBoot中各個層級結(jié)構(gòu)的具體實現(xiàn)
在SpringBoot項目中,常常會把代碼文件放入不同的包中,本文主要介紹了SpringBoot中各個層級結(jié)構(gòu)的具體實現(xiàn),具有一定的參考價值,感興趣的可以了解一下2024-05-05Java中常用解析工具jackson及fastjson的使用
今天給大家?guī)淼氖顷P(guān)于Java解析工具的相關(guān)知識,文章圍繞著jackson及fastjson的使用展開,文中有非常詳細的介紹及代碼示例,需要的朋友可以參考下2021-06-06Jackson使用示例-Bean、XML、Json之間相互轉(zhuǎn)換
Jackson是一個強大工具,可用于Json、XML、實體之間的相互轉(zhuǎn)換,JacksonXmlElementWrapper用于指定List等集合類,外圍標簽名,JacksonXmlProperty指定包裝標簽名,或者指定標簽內(nèi)部屬性名,JacksonXmlRootElement指定生成xml根標簽的名字,JacksonXmlText指定當(dāng)前這個值2024-05-05