spriing boot 启动报错:Cannot determine embedded database driver class for database type NONE
最近在学习使用spring boot。使用maven创建好工程,只引用需要用到的spring boot相关的jar包,除此之外没有任何的配置。
写了一个最简单的例子,如下所示:
package com.torlight; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ConfigurableApplicationContext; /**
* @since 2017.05.06
* @author acer
*
*/
@SpringBootApplication
public class Application { public static void main(String[] args) {
ApplicationContext appctx= SpringApplication.run(Application.class,args); System.out.println("appctx.getBeanDefinitionCount="+appctx.getBeanDefinitionCount());
try {
((ConfigurableApplicationContext)appctx).close();
} catch (Exception e) { /*ignore*/ }
}
}
运行程序后,控制台输出错误日志:
017-05-06 22:44:18.868 WARN 41648 --- [ restartedMain] ationConfigEmbeddedWebApplicationContext : 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$Tomcat.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.tomcat.jdbc.pool.DataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: 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 may need to active it (no profiles are currently active).
2017-05-06 22:44:18.871 INFO 41648 --- [ restartedMain] o.apache.catalina.core.StandardService : Stopping service Tomcat
2017-05-06 22:44:18.902 INFO 41648 --- [ restartedMain] utoConfigurationReportLoggingInitializer :
Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2017-05-06 22:44:18.907 ERROR 41648 --- [ restartedMain] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
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 (no profiles are currently active).
这是因为spring boot默认会加载org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration类,DataSourceAutoConfiguration类使用了@Configuration注解向spring注入了dataSource bean。因为工程中没有关于dataSource相关的配置信息,当spring创建dataSource bean因缺少相关的信息就会报错。
因为我仅仅只是使用spring boot来写一些很简单的例子来学习它,在Application类上增加@EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class})
阻止spring boot自动注入dataSource bean
package com.torlight; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ConfigurableApplicationContext; /**
* @since 2017.05.06
* @author acer
*
*/
@SpringBootApplication
@EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class})
public class Application { public static void main(String[] args) {
ApplicationContext appctx= SpringApplication.run(Application.class,args); System.out.println("appctx.getBeanDefinitionCount="+appctx.getBeanDefinitionCount());
try {
((ConfigurableApplicationContext)appctx).close();
} catch (Exception e) { /*ignore*/ }
}
}
spriing boot 启动报错:Cannot determine embedded database driver class for database type NONE的更多相关文章
- Springboot 之 启动报错-Cannot determine embedded database driver class for database type NONE
Springboot 之 启动报错-数据库 springboot项目在启动时,报如下错误: Error starting ApplicationContext. To display the auto ...
- 【报错】spring boot启动 报错 找不到实体类Not a managed type: class com.pisen.cloud.luna.feign.ten.beans.SysUser
Caused by: java.lang.IllegalArgumentException: Not a managed type: class com.pisen.cloud.luna.feign. ...
- Spring boot 启动报错 Failed to auto-configure a DataSource
1.Spring boot 启动报错 Failed to auto-configure a DataSource 参考资料https://blog.csdn.net/liuyinfei_java/ar ...
- spring Boot启动报错Initialization of bean failed; nested exception is java.lang.NoSuchMethodError: org.springframework.core.annotation.AnnotatedElementUtils.getAnnotationAttributes
spring boot 启动报错如下 org.springframework.context.ApplicationContextException: Unable to start web serv ...
- 解决spring boot启动报错java.lang.NoClassDefFoundError: ch/qos/logback/classic/Level
解决spring boot启动报错java.lang.NoClassDefFoundError: ch/qos/logback/classic/Level 学习了:https://blog.csdn. ...
- 【原创】大叔经验分享(67)spring boot启动报错
spring boot 启动报错: Caused by: java.lang.IllegalArgumentException: LoggerFactory is not a Logback Logg ...
- 报错Cannot determine embedded database driver class for database type NONE解决方法
由于我不需要数据库,启动springboot报错: Cannot determine embedded database driver class for database type NONE If ...
- SpringBoot项目报错Cannot determine embedded database driver class for database type NONE
原因: Cannot determine embedded database driver class for database type NONE 这是因为spring boot默认会加载org.s ...
- 新建Spring boot 启动报错 Failed to auto-configure a DataSource
今天学习springboot,使用idea创建项目.在选择组件时添加了mysq 然后在第一次启动的时候启动报错,错误信息如下: ***************************APPLICATI ...
随机推荐
- native生成策略:由Hibernate根据所使用的数据库支持能力从identity、sequence或者等生成策略中选择一种
increment生成策略:当Hibernate准备在数据库表中插入一条新记录时,首先从数据库表中获取当前主键字段的最大值,然后在最大值基础上加1,作为当前持久化对象的标识符属性值.这种策略即incr ...
- “Chaos”的算法之Floyd算法
倘若我们要在计算机上建立一个交通咨询系统则可以采用图的结构来表示实际的交通网络.其实现最基本的功能,求出任意两点间的最短路径, 求最短路径的经典方法有很多种,最常用的便是迪杰斯特拉算法和佛洛依德(Fl ...
- Python下opencv使用笔记(十)(图像频域滤波与傅里叶变换)
前面以前介绍过空间域滤波,空间域滤波就是用各种模板直接与图像进行卷积运算,实现对图像的处理,这个方案直接对图像空间操作,操作简单.所以也是空间域滤波. 频域滤波说究竟终于可能是和空间域滤波实现相同的功 ...
- fatal error: malformed or corrupted AST file: 'Unable to load module Darwin.pcm 问题解决
xcode5 编译project.偶然碰到了以下的问题: fatal error: malformed or corrupted AST file: 'Unable to load module &q ...
- Ubuntu 12.04.2 安装 Oracle11gR2
#step 1: groupadd -g 2000 dbauseradd -g 2000 -m -s /bin/bash -u 2000 griduseradd -g 2000 -m -s /bin/ ...
- C#------?和??运算符的作用
转载: http://www.cnblogs.com/zfanlong1314/archive/2012/02/26/2390456.html 1.?的作用 在处理数据库和其他包含不可赋值的元素的数据 ...
- day11<Java开发工具&常见对象>
Java开发工具(常见开发工具介绍) Java开发工具(Eclipse中HelloWorld案例以及汉化) Java开发工具(Eclipse的视窗和视图概述) Java开发工具(Eclipse工作空间 ...
- day03<Java语言基础+>
Java语言基础(逻辑运算符的基本用法) Java语言基础(逻辑运算符&&和&的区别) Java语言基础(位运算符的基本用法1) Java语言基础(位异或运算符的特点及面试题) ...
- 关于直播学习笔记-003-nginx-rtmp、srs、vlc、obs
服务器 1.nginx-rtmp:https://github.com/illuspas/nginx-rtmp-win32 2.srs:https://github.com/illuspas/srs- ...
- MYSQL IFNULL函数的使用
IFNULL函数是MYSQL数据库中最重要的函数之一,下面就对该函数的使用方面进行分析,希望对您能够有所帮助. 下文对MYSQL IFNULL函数的使用进行了详细的叙述,供您参考学习,如果您在MYSQ ...