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
把这个依赖注释掉就好了
原因
应用没有使用到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
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。
上一篇: 简介Winform中创建用户控件
推荐阅读
-
SpringBoot启动报错Failed to determine a suitable driver class
-
SpringBoot项目在启动时出现了Cannot determine embedded database driver class for database type NONE 错误
-
SpringBoot war包tomcat运行启动报错(Cannot determine embedded database driver class for
-
SpringBoot启动报错Cannot determine embedded database driver class for database type NONE
-
SpringBoot war包tomcat运行启动报错(Cannot determine embedded database driver class for