解决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.springframework.context.annotation.AnnotationConfigApplicationContext@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/DataSourceConfigurationDataSourceBeanCreationException: 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
------------------------我是分割线------------------
网上 找到了所谓的解决 方法:
1 2 3 4 5 6 7 8 9 10 11 | @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依赖:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | <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明显少了很多。
1 2 3 4 5 | <dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-starter</artifactId> <version> 1.3 . 0 </version> </dependency> |
最终,Spring Boot 启动成功!
__EOF__
作 者:ღKawaii
出 处:https://www.cnblogs.com/kmsfan/p/7189626.html
关于博主:一个普通的小码农,为了梦想奋斗
版权声明:署名 - 非商业性使用 - 禁止演绎,协议普通文本 | 协议法律文本。
声援博主:如果您觉得文章对您有帮助,可以点击文章右下角【推荐】一下。您的鼓励是博主的最大动力!

出处:http://www.cnblogs.com/kmsfan
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
欢迎大家加入KMSFan之家,以及访问我的优酷空间!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· 展开说说关于C#中ORM框架的用法!
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?