码迷,mamicode.com
首页 > 数据库 > 详细

Spring boot出现Cannot determine embedded database driver class for database type NONE

时间:2018-08-17 01:21:56      阅读:535      评论:0      收藏:0      [点我收藏+]

标签:文件中   current   出现   spring   rip   rmi   color   user   tap   

 

在spring boot项目中,我们在pom.xml文件中添加了mysql和mybatis的依赖,我们常常遇到下面这样的问题:

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 (no profiles are currently active).

出现这个问题,是因为spring boot在项目启动的时候会注入数据源,而我们在配置文件中又没有配置数据库,因此会报这样的错误。

解决办法:

1.当然是直接注释掉pom.xml文件中的mysql和mybatis的依赖,这样spring boot启动的时候当然不会注入数据源了,因此也就不会报错了。

2.在@SpringBootApplication中排除其注入

@SpringBootApplication(exclude={DataSourceAutoConfiguration.class,HibernateJpaAutoConfiguration.class})

3.直接在配置文件配置一下数据库连接就好了嘛,多简单的事,那当然就不会报错了。

spring.datasource.driverClassName=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/test
spring.datasource.username=root
spring.datasource.password=root

 

Spring boot出现Cannot determine embedded database driver class for database type NONE

标签:文件中   current   出现   spring   rip   rmi   color   user   tap   

原文地址:https://www.cnblogs.com/heqiyoujing/p/9490969.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!