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

在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

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

时间: 2024-11-06 03:50:07

Spring boot出现Cannot determine embedded database driver class for database type NONE的相关文章

spriing boot 启动报错:Cannot determine embedded database driver class for database type NONE

最近在学习使用spring boot.使用maven创建好工程,只引用需要用到的spring boot相关的jar包,除此之外没有任何的配置. 写了一个最简单的例子,如下所示: 1 package com.torlight; 2 3 import org.springframework.boot.SpringApplication; 4 import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 5 import

解决spring-boot启动中碰到的问题:Cannot determine embedded database driver class for database type NONE

问题 如下: 2017-07-16 08:50:57.436  INFO 13524 --- [           main] c.p.p.web.PointshopWebApplication        : Starting PointshopWebApplication on MSI with PID 13524 (D:\javaProject\com.ppdai.pointshop\pointshop-web\target\classes started by yangliweng

解决spring-boot启动中碰到的问题:Cannot determine embedded database driver class for database type NONE(转)

问题 如下: 2017-07-16 08:50:57.436  INFO 13524 --- [           main] c.p.p.web.PointshopWebApplication        : Starting PointshopWebApplication on MSI with PID 13524 (D:\javaProject\com.ppdai.pointshop\pointshop-web\target\classes started by yangliweng

springboot启动报错:Cannot determine embedded database driver class for database type NONE.

1 package cn.zb.test; 2 3 import org.springframework.boot.SpringApplication; 4 5 import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 6 7 import org.springframework.boot.autoconfigure.SpringBootApplication; 8 9 import org.springfram

报错Cannot determine embedded database driver class for database type NONE解决方法

由于我不需要数据库,启动springboot报错: Cannot determine embedded database driver class for database type NONE 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 ma

trouble shooting(Cannot determine embedded database driver class for database type NONE)

报错如下:***************************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 clas

spring boot 启动报错:Cannot determine embedded database driver class for database type NONE

错误原因:spring boot默认会加载org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration类,DataSourceAutoConfiguration类使用了@Configuration注解向spring注入了dataSource bean.因为工程中没有关于dataSource相关的配置信息,当spring创建dataSource bean因缺少相关的信息就会报错. 解决办法:第一种:在Applicat

springboot启动时报错Cannot determine embedded database driver class for database type NONE解决办法

springboot启动报错如下图: 出错原因:springboot启动时会自动注入数据源及配置jpa 解决办法: 1,在pom文件中加h2引用 <dependency> <groupId>com.h2database</groupId> <artifactId>h2</artifactId> <scope>runtime</scope></dependency> 2.在启动类上加上 @SpringBootAp

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

环境eclipse 4.7  jdk1.8    搭建springcloud子父项目报错 出现了这两种报错 解决  加上下面两个注解 @ComponentScan(basePackages = {"com.wf.zhang.springcloud.dao"}) @EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class}) @ComponentScan(basePackages = {"com.wf.