Cannot determine embedded database driver class for database type NONE

简介: 这个问题要从“ java.io.IOException: Server returned HTTP response code: 403 for URL: http://start.spring.

这个问题要从“ 

java.io.IOException: Server returned HTTP response code: 403 for URL: http://start.spring.io

”错误说起, 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: default
2017-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 hierarchy
2017-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.23
2017-12-29 17:28:53.564  INFO 4429 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2017-12-29 17:28:53.564  INFO 4429 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 2341 ms
2017-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 hierarchy
2017-12-29 17:28:54.725  INFO 4429 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> 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 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).
我认为错误产生的原因是:创建项目的时候添加了 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.Driver
spring.datasource.url=jdbc:mysql://
目录
相关文章
|
消息中间件 Linux
Linux - error: cannot open Packages database in /var/lib/rpm
Linux - error: cannot open Packages database in /var/lib/rpm
273 0
|
SQL BI 数据库
SQL Server 2012 The report server cannot open a connection to the report server database
案例环境:        操作系统版本:    Windows Server 2012 R2 Standard        数据库版本  :    SQL SERVER 2012 SP2 案例介绍:         今天进入一台新安装的SQL Server服务器的Reporting S...
1355 0
|
Java Spring Maven
深入Spring Boot:怎样排查 Cannot determine embedded database driver class for database type NONE
写在前面 这个demo来说明怎么一步步排查一个常见的spring boot AutoConfiguration的错误。 https://github.
3625 0
|
数据库 索引
error: cannot open Packages database in /var/lib/rpm
在使用rpm -ivh gcc-4.4.7-4.el6.x86_64.rpm命令安装GCC时,提示以下错误: rpmdb: Thread/process 3343/139858349385472 failed: Thread died in Berkeley DB library error:...
751 0
|
1月前
|
Oracle 关系型数据库 Linux
服务器Centos7 静默安装Oracle Database 12.2
服务器Centos7 静默安装Oracle Database 12.2
68 0
|
4月前
|
Oracle 关系型数据库 数据库
windows Oracle Database 19c 卸载教程
打开任务管理器 ctrl+Shift+Esc可以快速打开任务管理器,找到oracle所有服务然后停止。 停止数据库服务 在开始卸载之前,确保数据库服务已经停止。你可以使用以下命令停止数据库服务: net stop OracleServiceORCL Universal Installer 卸载Oracle数据库程序 一般情况运行Oracle自带的卸载程序,如使用Universal Installer 工具卸载。 点击开始菜单找到Oracle,然后点击Oracle安装产品,再点击Universal Installer。 点击之后稍等一会然后会进入进入下图界面,点击卸载产品。 选中要删除的Orac
100 1
|
5月前
|
存储 Oracle 关系型数据库
windows 使用 Oracle Database 19c
Oracle数据库是由美国Oracle Corporation(甲骨文公司)开发和提供的一种关系型数据库管理系统,它是一种强大的关系型数据库管理系统(RDBMS)。它使用表格(表)组织和存储数据,通过SQL语言进行数据管理。数据以表格形式存储,表之间可以建立关系。支持事务处理、多版本并发控制、安全性和权限控制。具有高可用性、容错性,支持分布式数据库和可扩展性。Oracle Corporation提供全面的支持和服务,使其成为企业级应用的首选数据库系统。
55 0
|
10月前
|
Oracle 关系型数据库 Linux
服务器Centos7 静默安装Oracle Database 12.2(下)
服务器Centos7 静默安装Oracle Database 12.2(下)
232 0
|
10月前
|
Oracle 安全 关系型数据库
服务器Centos7 静默安装Oracle Database 12.2(上)
服务器Centos7 静默安装Oracle Database 12.2(上)
91 0

热门文章

最新文章