【spring boot装载mybatis-plus】java.lang.IllegalStateException: Failed to load ApplicationContext

在尝试运行项目时遇到了Spring Boot数据源配置错误,具体表现为Bean创建失败,原因在于mybatis-plus的依赖配置不正确。问题在于使用了'mybatis-plus-core'而不是'mybatis-plus-boot-starter'。通过将pom.xml中的依赖替换为'mybatis-plus-boot-starter'版本3.4.2,解决了这个问题。
摘要由CSDN通过智能技术生成
 ## Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'dataSource': Unsatisfied dependency expressed through field 'basicProperties'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'spring.datasource-org.springframework.boot.autoconfigure.jdbc.DataSourceProperties': Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.autoconfigure.jdbc.DataSourceProperties]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/springframework/dao/DataAccessException

运行出现的错误,找了很多,但都不是答案,最终发现问题出现在pom.xml文件上
*因为不是手动导包,而是在问题上导入的包所以,mybatis-plus的包配置出现的问题
下面展示 问题

        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-core</artifactId>
            <version>3.4.2</version>
            <scope>compile</scope>
        </dependency>

下面展示 解决方案

      <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-boot-starter</artifactId>
            <version>3.4.2</version>
        </dependency>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值