测试时,报错(还没加数据库)

在执行@SpringBootTest注解的UserMapperTest类时,遇到了一个BeanCreationException,具体是由于在初始化名为dataSource的bean时,工厂方法失败。错误源头在于无法实例化com.zaxxer.hikari.HikariDataSource,进一步的原因是SpringBoot未能确定合适的数据库驱动类。

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

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Failed to determine a suitable driver class
@SpringBootTest
public class UserMapperTest {
    @Test
    public void hello() {
        System.out.println("hello");
    }
}

报错原因:

报错时: 

纠正:

 成功 √

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值