解决 Cannot determine embedded database driver class for database type NONE

问题

springboot项目报错mysql

Cannot determine embedded database driver class for database type NONEredis

具体以下:spring

***************************
APPLICATION FAILED TO START
***************************

Description:

Cannot determine embedded database driver class for database type NONE

Action:

If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (the profiles "dev" are currently active).

其中,相关yml文件以下:sql

spring:
  redis:
    host: localhost
    password:
    port: 6379
    timeout: 1000
    pool:
      max-idle: 100     # 链接池中的最大空闲链接
      min-idle: 1       # 链接池中的最小空闲链接
      max-active: 1000  #链接池最大链接数(使用负值表示没有限制)
      max-wait: -1      # 链接池最大阻塞等待时间(使用负值表示没有限制)

这里没有配置mysql的连接,是由于该项目不须要与mysql进行交互。apache

缘由

springboot 要建立一个DataSource对象:tomcat

  • 尝试查找dataSourceClass,若是找到,条件就成立。那么debug下,能够发现查找到的dataSourceClass是:org.apache.tomcat.jdbc.pool.DataSource 。springboot

  • 那么再看下org.apache.tomcat.jdbc.pool.DataSource这个类是从哪里来的呢?mybatis

  • 从maven依赖树能够看到,依赖是来自:spring-boot-starter-jdbc。因此是应用依赖了spring-boot-starter-jdbc,可是并无配置DataSource引发的问题。maven

<dependency>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>

解决

pom中删除以下依赖(由于该依赖向上依赖了spring-boot-starter-jdbc)spring-boot

<dependency>
	<groupId>org.mybatis.spring.boot</groupId>
	<artifactId>mybatis-spring-boot-starter</artifactId>
	<version>1.1.1</version>
</dependency>

参考连接

相关文章
相关标签/搜索