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 ... 
随机推荐
- TextView不用获取焦点也能实现跑马灯
			1.写一个类继承TextView package com.example.tt; import android.content.Context; import android.graphics.Rec ... 
- CentOS基础命令大全
			1.关机 (系统的关机.重启以及登出 ) 的命令 shutdown -h now 关闭系统(1) init 0 关闭系统(2) telinit 0 关闭系统(3) shutdown -h hours: ... 
- JavaScript-事件冒泡简介及应用
			一.什么是事件冒泡 在一个对象上触发某类事件(比如单击onclick事件),如果此对象定义了此事件的处理程序,那么此事件就会调用这个处理程序,如果没有定义此事件处理程序或者事件返回true,那么这个事 ... 
- iOS获取时间、日期
			//获取当前时间 NSDateFormatter *formatter = [[[NSDateFormatter alloc] init]autorelease]; [formatter setLoc ... 
- Linux配置防火墙,开启80port、3306port 可能会遇到的小问题
			 vi /etc/sysconfig/iptables -A INPUT -m state –state NEW -m tcp -p tcp –dport 80 -j ACCEPT(同意80端口通 ... 
- oracle当前月添加一列显示前几个月的累计值
			create table test_leiji(rpt_month_id number(8), current_month NUMBER(12,2)); ... 
- Unity 移动端的复制这么写
			游戏上线很久了,有些玩家慢慢就流失了,为了让刚流失的玩家再度回归所以做了召回功能!如果一个200级的玩家10天没上线且成功召回的,就会给予召回玩家丰厚的奖励! Q:那如何召回这个流失的玩家呢? A:召 ... 
- Ubuntu 16.04 获取 root 用户权限并以 root权限登录
			http://blog.csdn.net/csdn_flyyoung/article/details/52966583 
- MySQL<事务与存储过程>
			事务与存储过程 事务管理 事务的概念 谓的事务就是针对数据库的一组操作,它可以由一条或多条SQL语句组成,同一个事务的操作具备同步的特点,即事务中的语句要么都执行,要么都不执行. 事务的使用 开启事务 ... 
- 写了一个简单的CGI Server
			之前看过一些开源程序的源码,也略微知道些Apache的CGI处理程序架构,于是用了一周时间,用C写了一个简单的CGI Server,代码算上头文件,一共1200行左右,难度中等偏上,小伙伴可以仔细看看 ... 
