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

question

springboot project error

Cannot determine embedded database driver class for database type NONE

details as follows:

***************************
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).

Among them, the relevant yml files are as follows:

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

There is no link to configure mysql here because the project does not need to interact with mysql.

reason

springboot To create a DataSource object:

  • Try to find dataSourceClass, if found, the condition is true. Then under debug, you can find that the dataSourceClass found is: org.apache.tomcat.jdbc.pool.DataSource.

  • Then look at where does the class org.apache.tomcat.jdbc.pool.DataSource come from?

  • As you can see from the maven dependency tree, the dependencies are from: spring-boot-starter-jdbc. So the application depends on spring-boot-starter-jdbc, but there is no problem caused by configuring DataSource.

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

solve

Delete the following dependencies from the pom (because the dependency is upwardly dependent spring-boot-starter-jdbc)

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

Reference link

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325360210&siteId=291194637