欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

SpringBoot启动报错Failed to determine a suitable driver class

程序员文章站 2023-12-04 15:52:52
springboot启动报错如下 error starting applicationcontext. to display the conditions repor...

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

SpringBoot启动报错Failed to determine a suitable driver class

把这个依赖注释掉就好了

SpringBoot启动报错Failed to determine a suitable driver class

原因

应用没有使用到datasource,但是在pom.xml里引入了mybatis-spring-boot-starter

问题解决办法

有两种:

把mybatis-spring-boot-starter的依赖去掉,这样就不会触发spring boot相关的代码

把spring boot自动初始化datasource相关的代码禁止掉

禁止的办法有两种:

在启动类的@springbootapplication加上

@springbootapplication(exclude = { datasourceautoconfiguration.class, datasourcetransactionmanagerautoconfiguration.class })

在application.properties里配置:

spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.jdbc.datasourceautoconfiguration,org.springframework.boot.autoconfigure.jdbc.datasourcetransactionmanagerautoconfiguration

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。