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.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
10
11 @SpringBootApplication
12
13 public class Application {
14
15 public static void main(String[] args) {
16
17 SpringApplication.run(Application.class, args);
18
19    }
20
21 }

点击run启动后报错如下:

  .   ____          _            __ _ _
 /\\ / ___‘_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | ‘_ | ‘_| | ‘_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  ‘  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::       (v1.5.10.RELEASE)

2019-06-02 10:13:25.294  INFO 10868 --- [           main] cn.zb.test.Application                   : Starting Application on C300ZA8PPUJ5JRS with PID 10868 (F:\eclipse\workspace\springboot_parent\springboot_web\target\classes started by ABO in F:\eclipse\workspace\springboot_parent\springboot_web)
2019-06-02 10:13:25.303  INFO 10868 --- [           main] cn.zb.test.Application                   : No active profile set, falling back to default profiles: default
2019-06-02 10:13:25.361  INFO 10868 --- [           main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot[email protected]f08448: startup date [Sun Jun 02 10:13:25 CST 2019]; root of context hierarchy
2019-06-02 10:13:25.914  WARN 10868 --- [           main] o.m.s.mapper.ClassPathMapperScanner      : No MyBatis mapper was found in ‘[cn.zb.test]‘ package. Please check your configuration.
2019-06-02 10:13:27.616  INFO 10868 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
2019-06-02 10:13:27.628  INFO 10868 --- [           main] o.apache.catalina.core.StandardService   : Starting service Tomcat
2019-06-02 10:13:27.629  INFO 10868 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.11
2019-06-02 10:13:27.736  INFO 10868 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2019-06-02 10:13:27.736  INFO 10868 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 2378 ms
2019-06-02 10:13:27.900  INFO 10868 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Mapping servlet: ‘dispatcherServlet‘ to [/]
2019-06-02 10:13:27.905  INFO 10868 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: ‘characterEncodingFilter‘ to: [/*]
2019-06-02 10:13:27.905  INFO 10868 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: ‘hiddenHttpMethodFilter‘ to: [/*]
2019-06-02 10:13:27.905  INFO 10868 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: ‘httpPutFormContentFilter‘ to: [/*]
2019-06-02 10:13:27.905  INFO 10868 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: ‘requestContextFilter‘ to: [/*]
2019-06-02 10:13:28.412  INFO 10868 --- [           main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot[email protected]f08448: startup date [Sun Jun 02 10:13:25 CST 2019]; root of context hierarchy
2019-06-02 10:13:28.501  INFO 10868 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/index/{name}]}" onto public java.lang.String cn.zb.test.HelloWorldController.index(java.lang.String)
2019-06-02 10:13:28.506  INFO 10868 --- [           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)
2019-06-02 10:13:28.507  INFO 10868 --- [           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)
2019-06-02 10:13:28.541  INFO 10868 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2019-06-02 10:13:28.541  INFO 10868 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2019-06-02 10:13:28.582  INFO 10868 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2019-06-02 10:13:28.634  WARN 10868 --- [           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).
2019-06-02 10:13:28.637  INFO 10868 --- [           main] o.apache.catalina.core.StandardService   : Stopping service Tomcat
2019-06-02 10:13:28.648  WARN 10868 --- [ost-startStop-1] o.a.c.loader.WebappClassLoaderBase       : The web application [ROOT] appears to have started a thread named [Abandoned connection cleanup thread] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
 java.lang.Object.wait(Native Method)
 java.lang.ref.ReferenceQueue.remove(Unknown Source)
 com.mysql.jdbc.AbandonedConnectionCleanupThread.run(AbandonedConnectionCleanupThread.java:40)
2019-06-02 10:13:28.660  INFO 10868 --- [           main] utoConfigurationReportLoggingInitializer : 

Error starting ApplicationContext. To display the auto-configuration report re-run your application with ‘debug‘ enabled.
2019-06-02 10:13:28.665 ERROR 10868 --- [           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).

这是因为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 cn.zb.test;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
@SpringBootApplication
@EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class})
public class Application {

    public static void main(String[] args) {

         SpringApplication.run(Application.class, args);
    }

}

这样就可以正常启动啦!

.

原文地址:https://www.cnblogs.com/abo9527/p/10962067.html

时间: 2024-08-07 07:37:21

springboot启动报错:Cannot determine embedded database driver class for database type NONE.的相关文章

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

springboot启动报错退出,To display the conditions report re-run your application with &#39;debug&#39; enabled.

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.2019-01-19 12:01:39.870 ERROR 8324 --- [  restartedMain] o.s.b.d.LoggingFailureAnalysisReporter   : ***************************APPLICATIO

springboot启动报错start bean &#39;eurekaAutoServiceRegistration&#39; NullPointerException

解决方案参考:https://blog.csdn.net/hhj13978064496/article/details/82825365 我将eureka的依赖包放到了依赖包的最下面,启动报错, 如下: <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId&

springboot启动报错:&quot;Error starting ApplicationContext. To display the conditions report re-run your application with &#39;debug&#39; enabled.&quot;

报错内容 java.lang.Object.wait(Native Method)java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:143)com.mysql.jdbc.AbandonedConnectionCleanupThread.run(AbandonedConnectionCleanupThread.java:41)2019-02-14 14:58:00.326 INFO 17688 --- [ main] Condition

报错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

springboot启动报错:Failed to configure a DataSource

一.背景 springboot的出现,让项目搭建变得更方便快捷,同时简化掉很多的样板化配置代码,提高开发效率. 通过idea生成springboot项目,启动报错:Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured. 通过错误不难看出是因为dataSource的url配置缺失导致,但是新生成的项目并没有使用到jdbc,为什

Springboot启动报错:Failed to determine a suitable driver class

Description: Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured. Reason: Failed to determine a suitable driver class 原因: 没有配置数据源,但springboot默认启用了数据源配置 解决办法: 启动类添加exclude参数,不启用DataSource 原

Springboot启动报错:child container failed during start

Caused by: java.lang.NoSuchMethodError: javax.servlet.ServletContext.getVirtualServerName()Ljava/lang/String;引入了一个hsf pom文件后后,翻到异常堆栈最下面发现是:ServletContext没有getVirtualServerName方法,原因是pom冲突,解决方案:在hsf里面先排除就得servlet-api,在引入最新的:A child container failed dur

SpringBoot启动报错【This application has no explicit mapping for /error.....】

今天做SpringBoot小例子,在请求controller层的时候出现如下问题. Whitelabel Error Page This application has no explicit mapping for /error, so you are seeing this as a fallback. Wed Dec 14 16:35:25 CST 2016 There was an unexpected error (type=Not Found, status=404). No mes