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

SpringBoot Initializer 新建SpringBoot项目添加一个简单控制器,启动报错如下:

1 . ____ _ __ _ _ 2 /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ 3( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ 4 \\/ ___)| |_)| | | | | || (_| | ) ) ) ) 5 ' |____| .__|_| |_|_| |_\__, | / / / / 6 =========|_|==============|___/=/_/_/_/ 7 :: Spring Boot :: (v2.1.8.RELEASE) 8 92019-09-09 10:37:16.750 INFO 11232 --- [ main] com.dongdong.demo.DemoApplication : Starting DemoApplication on PC-20170304VFOZ with PID 11232 (E:\Spring\Projects\demo\target\classes started by Administrator in E:\Spring\Projects\demo) 102019-09-09 10:37:16.752 INFO 11232 --- [ main] com.dongdong.demo.DemoApplication : No active profile set, falling back to default profiles: default 112019-09-09 10:37:17.711 INFO 11232 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data repositories in DEFAULT mode. 122019-09-09 10:37:17.730 INFO 11232 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 16ms. Found 0 repository interfaces. 132019-09-09 10:37:18.023 INFO 11232 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$3d0e1f1a] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 142019-09-09 10:37:18.327 INFO 11232 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http) 152019-09-09 10:37:18.359 INFO 11232 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat] 162019-09-09 10:37:18.360 INFO 11232 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.24] 172019-09-09 10:37:18.476 INFO 11232 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext 182019-09-09 10:37:18.476 INFO 11232 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1645 ms 192019-09-09 10:37:18.732 INFO 11232 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor' 202019-09-09 10:37:18.842 WARN 11232 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Failed to determine a suitable driver class 212019-09-09 10:37:18.843 INFO 11232 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Shutting down ExecutorService 'applicationTaskExecutor' 222019-09-09 10:37:18.846 INFO 11232 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat] 232019-09-09 10:37:18.860 INFO 11232 --- [ main] ConditionEvaluationReportLoggingListener : 24 25Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled. 262019-09-09 10:37:18.864 ERROR 11232 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter : 27 28*************************** 29APPLICATION FAILED TO START 30*************************** 31 32Description: 33 34Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured. 35 36Reason: Failed to determine a suitable driver class 37 38 39Action: 40 41Consider the following: 42 If you want an embedded database (H2, HSQL or Derby), please put it on the classpath. 43 If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active). 44 45 46Process 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

搞定!

点赞
收藏

评论区

加载中...

相关推荐

MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1

文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s

Oracle 分组与拼接字符串同时使用

SELECTT.,ROWNUMIDFROM(SELECTT.EMPLID,T.NAME,T.BU,T.REALDEPART,T.FORMATDATE,SUM(T.S0)S0,MAX(UPDATETIME)CREATETIME,LISTAGG(TOCHAR(

MySQL部分从库上面因为大量的临时表tmp_table造成慢查询

背景描述Time:20190124T00:08:14.70572408:00User@Host:@Id:Schema:sentrymetaLast_errno:0Killed:0Query_time:0.315758Lock_

皕杰报表之UUID

​在我们用皕杰报表工具设计填报报表时,如何在新增行里自动增加id呢?能新增整数排序id吗?目前可以在新增行里自动增加id,但只能用uuid函数增加UUID编码,不能新增整数排序id。uuid函数说明:获取一个UUID,可以在填报表中用来创建数据ID语法:uuid()或uuid(sep)参数说明:sep布尔值,生成的uuid中是否包含分隔符'',缺省为

手写Java HashMap源码

HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程22

2020年前端实用代码段,为你的工作保驾护航

有空的时候,自己总结了几个代码段,在开发中也经常使用,谢谢。1、使用解构获取json数据let jsonData  id: 1,status: "OK",data: 'a', 'b';let  id, status, data: number   jsonData;console.log(id, status, number )