Spring Boot运行发生异常:Factory method 'dataSource' threw exception; nested exception is org.springframe

本文介绍了一种常见的Spring Boot应用中数据源配置异常的问题,该问题表现为无法确定嵌入式数据库驱动类。文中提供了具体的异常堆栈信息,并给出了通过在启动类的@EnableAutoConfiguration注解中使用exclude属性来排除特定自动配置类的方法,以此解决数据源配置异常。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

异常:

 Caused by: 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).


原因:

 maven依赖包冲突,有重复的依赖。


解决:



   在启动类的@EnableAutoConfiguration添加exclude = {DataSourceAutoConfiguration.class},排除此类的autoconfig。启动以后就可以正常运行。



 


评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值