mybatis-plus踩坑日记

今天心血来潮,搭建一套项目,记录一下引入mybatis-plus导致的错误。

一:在pom文件中引入了mybatis-plus,但是并没有生效。也没有打印出mybatis-plus的logo。

出现了这样的一个错误:

Application run failed

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'deptServiceImpl': Unsatisfied dependency expressed through field 'baseMapper'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.heqiang.springcloud.dao.DeptMapper' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}

引入的是:

            <dependency>
                <groupId>com.baomidou</groupId>
                <artifactId>mybatis-plus</artifactId>
                <version>3.3.2</version>
            </dependency>

实际上使用mybatis-plus是需要mybatis-plus-boot-starter的

修改为:

            <dependency>
                <groupId>com.baomidou</groupId>
                <artifactId>mybatis-plus-boot-starter</artifactId>
                <version>3.3.2</version>
            </dependency>

二:错误

Caused by: java.lang.ClassNotFoundException: org.mybatis.logging.LoggerFactory或者

com.baomidou.mybatisplus.core.MybatisConfiguration.getLanguageDriver(

原因是pom文件冲突了。应为mybatis-plus和mybatis以及pagehelper都会冲突。所以需要排查一下下

第一种,把pagehelper的mybatis排除,

第二种:删除mybatis-spring-boot-starter 的pom文件,直接使用mybatis-plus-boot-starter的mybatis,所以在mybatis-plus-boot-starter中不要排除mybatis。

第三种:直接在pom依赖树中查看什么地方使用到了mybatis,然后去进行排除

 三:版本不兼容

直接去maven仓库去找到mybatis-plus的版本,然后看版本的兼容,比如3.3.2版本的mybatis-plus最低要求spring boot为2.3.0.RELEASE

maven仓库mybatis-plus地:https://mvnrepository.com/artifact/com.baomidou/mybatis-plus-boot-starter

四:在mapper层缺少@Mapper或者是启动类上面缺少@MapperSacn,二者有一个就可。

  • 4
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值