使用idea在Springboot项目启动时报错描述 Cannot determine embedded database driver class for database type NONE

Springboot项目启动时报错
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).
在这里插入图片描述
原因是pom中引入了mybatis-spring-boot-starter依赖 ,Spring boot默认会加载org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration类,DataSourceAutoConfiguration类使用了@Configuration注解向Spring注入了DataSource bean。因为工程中缺少关于DataSource相关的配置信息,当Spring创建DataSource bean因缺少相关的信息就会报错。
解决方法:
可以在主程序上加@EnableAutoConfiguration(exclude = {DataSourceAutoConfiguration.class}),如果加了这个注解之后又报错Attribute should be specified via @SpringBootApplication就删了上述标签,直接在@SpringBootApplication标签后加(exclude = {DataSourceAutoConfiguration.class})
在这里插入图片描述
搞定。
但要是你项目需要数据库,决不能配@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class}),可以试试向pom依赖中添加依赖
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>

借鉴:https://blog.youkuaiyun.com/Master_Shifu_/article/details/80420099

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值