解决spring-boot启动中碰到的问题:Cannot determine embedded database driver class for database type NONE

问题 如下:

2017-07-16 08:50:57.436  INFO 13524 --- [           main] c.p.p.web.PointshopWebApplication        : Starting PointshopWebApplication on MSI with PID 13524 (D:\javaProject\com.ppdai.pointshop\pointshop-web\target\classes started by yangliweng in D:\javaProject\com.ppdai.pointshop)

2017-07-16 08:50:57.436  INFO 13524 --- [           main] c.p.p.web.PointshopWebApplication        : No active profile set, falling back to default profiles: default

2017-07-16 08:50:57.478  INFO 13524 --- [           main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.spring[email protected]179bb86: startup date [Sun Jul 16 08:50:57 GMT+08:00 2017]; root of context hierarchy

2017-07-16 08:50:57.798  WARN 13524 --- [           main] o.m.s.mapper.ClassPathMapperScanner      : No MyBatis mapper was found in ‘[com.ppdai.pointshop.web.controller, com.ppdai.pointshop.web]‘ package. Please check your configuration.

2017-07-16 08:50:57.829  INFO 13524 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode!

2017-07-16 08:50:58.001  WARN 13524 --- [           main] o.h.v.m.ParameterMessageInterpolator     : HV000184: ParameterMessageInterpolator has been chosen, EL interpolation will not be supported

2017-07-16 08:50:58.151  WARN 13524 --- [           main] o.h.v.m.ParameterMessageInterpolator     : HV000184: ParameterMessageInterpolator has been chosen, EL interpolation will not be supported

2017-07-16 08:50:58.224  WARN 13524 --- [           main] s.c.a.AnnotationConfigApplicationContext : 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-07-16 08:50:58.240  INFO 13524 --- [           main] utoConfigurationReportLoggingInitializer :

Error starting ApplicationContext. To display the auto-configuration report re-run your application with ‘debug‘ enabled.

2017-07-16 08:50:58.240 ERROR 13524 --- [           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).

Process finished with exit code 1

------------------------我是分割线------------------

网上 找到了所谓的解决 方法:

@SpringBootApplication(exclude = {

		DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class
},scanBasePackages = {"com.ppdai.pointshop.web.controller"}
)
public class PointshopWebApplication {

	public static void main(String[] args) {
		SpringApplication.run(PointshopWebApplication.class, args);
	}
}

  但是很 遗憾 ,没用。

于是 用maven下载 好springboot 的源码,然后断点调试 进去 ,看看 是什么情况,最后 发现了问题的所在:

因为我这是一个新 项目 ,还 没有 配置数据源 ,但是我又想在 没配置数据源的情况 下去 启动项目,该怎么办呢 ?网上找到的方法是无效的,于是我做了一个大胆的猜测:肯定是某个地方加载了这个bean,因为 这是 一个新项目,所以 我觉得 启动加载的可能性很大,而启动 加载 只有 POM文件 里面的依赖才 有可能办到。下面 是 我的dependency依赖:

	<dependencies>
		<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-autoconfigure -->
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-autoconfigure</artifactId>
			<version>1.5.4.RELEASE</version>
		</dependency>
		<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot -->
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot</artifactId>
			<version>1.5.4.RELEASE</version>
		</dependency>

		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-aop</artifactId>
			<version>1.5.4.RELEASE</version>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-data-redis</artifactId>
			<version>1.5.4.RELEASE</version>
		</dependency>
		<dependency>
			<groupId>org.mybatis.spring.boot</groupId>
			<artifactId>mybatis-spring-boot-starter</artifactId>
			<version>1.3.0</version>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-web</artifactId>
			<version>1.5.4.RELEASE</version>
		</dependency>

		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-tomcat</artifactId>
			<version>1.5.4.RELEASE</version>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-test</artifactId>
			<version>1.5.4.RELEASE</version>
			<scope>test</scope>
		</dependency>

		<!-- https://mvnrepository.com/artifact/org.springframework/spring-core -->
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-core</artifactId>
			<version>4.3.9.RELEASE</version>
		</dependency>
		<!-- https://mvnrepository.com/artifact/org.springframework/spring-context -->
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-context</artifactId>
			<version>4.3.9.RELEASE</version>
		</dependency>

	</dependencies>

  一个个排查,最后查到org.mybatis.spring.boot这个依赖 ,注释掉即可,可以发现,调试的时候 beannames明显少了很多。

<dependency>
   <groupId>org.mybatis.spring.boot</groupId>
   <artifactId>mybatis-spring-boot-starter</artifactId>
   <version>1.3.0</version>
</dependency>

最终,Spring Boot 启动成功!

 
时间: 2024-10-26 21:29:24

解决spring-boot启动中碰到的问题:Cannot determine embedded database driver class for database type NONE的相关文章

解决spring boot启动报错java.lang.NoClassDefFoundError: ch/qos/logback/classic/Level

学习了:https://blog.csdn.net/yunfeng482/article/details/78106433 没想到啊:我都看见了,idea也反编不了: 没想到要重新下载啊: 原文地址:https://www.cnblogs.com/stono/p/9126417.html

解决spring-boot启动中碰到的问题:Cannot determine embedded database driver class for database type NONE(转)

问题 如下: 2017-07-16 08:50:57.436  INFO 13524 --- [           main] c.p.p.web.PointshopWebApplication        : Starting PointshopWebApplication on MSI with PID 13524 (D:\javaProject\com.ppdai.pointshop\pointshop-web\target\classes started by yangliweng

Spring Boot 2中对于CORS跨域访问的快速支持

原文:https://www.jianshu.com/p/840b4f83c3b5 目前的程序开发,大部分都采用前后台分离.这样一来,就都会碰到跨域资源共享CORS的问题.Spring Boot 2 对此提供了很好的解决方法. 更多CORS介绍,请看这里: CORS介绍 1.注解实现 在Spring Boot 2中,提供了注解的方式来对CORS跨域访问进行支持. 1.1 在方法上注解 可以将@CrossOrigin注解在方法上.这样该方法可以被跨域访问. 在方法上标注 1.2 在Controll

Spring boot 启动报错:com.mongodb.MongoSocketOpenException: Exception opening socket

详细错误信息: com.mongodb.MongoSocketOpenException: Exception opening socket at com.mongodb.connection.SocketStream.open(SocketStream.java:63) ~[mongodb-driver-core-3.4.2.jar:na] at com.mongodb.connection.InternalStreamConnection.open(InternalStreamConnect

Spring Boot启动原理解析

Spring Boot启动原理解析http://www.cnblogs.com/moonandstar08/p/6550758.html 前言 前面几章我们见识了SpringBoot为我们做的自动配置,确实方便快捷,但是对于新手来说,如果不大懂SpringBoot内部启动原理,以后难免会吃亏.所以这次博主就跟你们一起一步步揭开SpringBoot的神秘面纱,让它不在神秘. 正文 我们开发任何一个Spring Boot项目,都会用到如下的启动类 从上面代码可以看出,Annotation定义(@Sp

spring boot启动原理步骤分析

spring boot最重要的三个文件:1.启动类 2.pom.xml 3.application.yml配置文件 一.启动类->main方法 1.spring boot通过fat jar方式用jdk命令java -jar jarname.jar启动的. fat jar就是包含被引用jar包的jar,因为会包含很多jar包,所以称为fat,肥胖. 2.spring  boot通过static void main方法启动,main方法是java程序总是最先运行的地方,这个是由jvm虚拟机决定的.任

Spring Boot启动过程(四):Spring Boot内嵌Tomcat启动

之前在Spring Boot启动过程(二)提到过createEmbeddedServletContainer创建了内嵌的Servlet容器,我用的是默认的Tomcat. private void createEmbeddedServletContainer() { EmbeddedServletContainer localContainer = this.embeddedServletContainer; ServletContext localServletContext = getServ

Spring Boot启动过程及回调接口汇总

Spring Boot启动过程及回调接口汇总 链接: https://www.itcodemonkey.com/article/1431.html 来自:chanjarster (Daniel Qian) 注:本文基于spring-boot 1.4.1.RELEASE, spring 4.3.3.RELEASE撰写. 启动顺序 Spring boot的启动代码一般是这样的: 1 2 3 4 5 6 @SpringBootApplication public class SampleApplica

Spring Boot 启动报错:LoggingFailureAnalysisReporter

17:57:19: Executing task 'bootRun'... Parallel execution with configuration on demand is an incubating feature.:thinkvenus-common:compileJava:thinkvenus-tool:processResources UP-TO-DATE:thinkvenus-common:compileJava UP-TO-DATE:thinkvenus-common:proce