当前位置: 移动技术网 > IT编程>开发语言>Java > SpringBoot启动报错Failed to determine a suitable driver class

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

2019年07月19日  | 移动技术网IT编程  | 我要评论

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


把这个依赖注释掉就好了

原因

应用没有使用到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

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

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网