博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Cannot determine embedded database driver class for database type NONE
阅读量:7120 次
发布时间:2019-06-28

本文共 6535 字,大约阅读时间需要 21 分钟。

这个问题要从“ 

”错误说起,
eclipse 
创建
 spring boot 
项目
 遇到错误:java.io.IOException: Server returned HTTP response code: 403 for URL: http://start.spring.io

然后就在网页上创建项目下载,新建Maven工程,修改Pom.xml 文件……

完整错误信息如下:

2017-12-29 17:28:51.149  INFO 4429 --- [           main] com.wanyu.fams.App                       : Starting App on avenMac.local with PID 4429 (/Users/aven/Documents/workspace/fams/fams/target/classes started by aven in /Users/aven/Documents/workspace/fams/fams)2017-12-29 17:28:51.153  INFO 4429 --- [           main] com.wanyu.fams.App                       : No active profile set, falling back to default profiles: default2017-12-29 17:28:51.228  INFO 4429 --- [           main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@4e7912d8: startup date [Fri Dec 29 17:28:51 CST 2017]; root of context hierarchy2017-12-29 17:28:52.062  WARN 4429 --- [           main] o.m.s.mapper.ClassPathMapperScanner      : No MyBatis mapper was found in '[com.wanyu.fams]' package. Please check your configuration.2017-12-29 17:28:53.358  INFO 4429 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)2017-12-29 17:28:53.384  INFO 4429 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]2017-12-29 17:28:53.386  INFO 4429 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.232017-12-29 17:28:53.564  INFO 4429 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext2017-12-29 17:28:53.564  INFO 4429 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 2341 ms2017-12-29 17:28:53.904  INFO 4429 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Mapping servlet: 'dispatcherServlet' to [/]2017-12-29 17:28:53.913  INFO 4429 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'characterEncodingFilter' to: [/*]2017-12-29 17:28:53.914  INFO 4429 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]2017-12-29 17:28:53.915  INFO 4429 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'httpPutFormContentFilter' to: [/*]2017-12-29 17:28:53.915  INFO 4429 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'requestContextFilter' to: [/*]2017-12-29 17:28:54.580  INFO 4429 --- [           main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@4e7912d8: startup date [Fri Dec 29 17:28:51 CST 2017]; root of context hierarchy2017-12-29 17:28:54.725  INFO 4429 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity
> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)2017-12-29 17:28:54.727 INFO 4429 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)2017-12-29 17:28:54.805 INFO 4429 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]2017-12-29 17:28:54.805 INFO 4429 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]2017-12-29 17:28:54.929 INFO 4429 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]2017-12-29 17:28:55.030 WARN 4429 --- [ main] 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-12-29 17:28:55.034 INFO 4429 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]2017-12-29 17:28:55.064 INFO 4429 --- [ main] utoConfigurationReportLoggingInitializer : Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.2017-12-29 17:28:55.072 ERROR 4429 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter : ***************************APPLICATION FAILED TO START***************************Description:Cannot determine embedded database driver class for database type NONEAction: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).
我认为错误产生的原因是:创建项目的时候添加了 MyBatis 依赖,但却没有添加对应的数据库配置。

分析原因

这是因为spring boot 会默认加载org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration这个类,

DataSourceAutoConfiguration类使用了@Configuration注解向spring注入了dataSource bean。因为工程中没有关于dataSource相关的配置信息,当spring创建dataSource bean因缺少相关的信息就会报错。

解决方案一

在类定义上增加@EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class})的注解。

解决方案二

在 application.properties 文件中添加数据库配置,例如:

#spring.datasource.type=com.mysql.jdbc.Driverspring.datasource.url=jdbc:mysql://

转载地址:http://mvsel.baihongyu.com/

你可能感兴趣的文章
PostgreSql Lock锁
查看>>
html5游戏引擎
查看>>
leetcode 29. Divide Two Integers
查看>>
Mobius反演定理-BZOJ2154
查看>>
InOrder Tree(Binary List Tree)
查看>>
三种背包问题
查看>>
第四十九篇、跳转设置界面
查看>>
MATLAB脚本显示滤波器系数
查看>>
day19<异常&File类>
查看>>
JAVASCRIPT 基本数据类型
查看>>
《你必须知道的.NET》--简易不简单:认识枚举(Ⅲ)
查看>>
Memcached(四)Memcached的CAS协议
查看>>
python 多进程multiprocessing 模块
查看>>
初步学习Django-第一篇:创建项目
查看>>
SpringBoot系列六:SpringBoot整合Tomcat
查看>>
SpringCloud系列五:Ribbon 负载均衡(Ribbon 基本使用、Ribbon 负载均衡、自定义 Ribbon 配置、禁用 Eureka 实现 Ribbon 调用)...
查看>>
根据id来实现小程序tab切换,
查看>>
003——数组(三)count()reset()end()prev()next()current()
查看>>
20060516: 实现圆角div效果
查看>>
Vim 快捷键整理
查看>>