关于加入Mybatis之后测试报错的情况

笔者尝试了网上的各种方法,mapper映射也没问题,注解写的也没问题,最后败在了依赖冲突上,原因是用SpringBoot3.x.x 搭配了 MyBatis2.x.x 使用,谨以此文章告诫自己不要再犯这种低级错误。

已纠正:

<dependency>
    <groupId>org.mybatis.spring.boot</groupId>
    <artifactId>mybatis-spring-boot-starter</artifactId>
    <version>3.0.4</version>
</dependency>

另:注意在启动类前加上 @MapperScan 注解

@MapperScan("com.coder.community.dao")

 原错误警告见下:

2025-03-30T02:19:18.668+08:00  WARN 25416 --- [community] [           main] o.s.w.c.s.GenericWebApplicationContext   : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'userMapper' defined in file [D:\Java\toWork\niu\community\target\classes\com\coder\community\dao\UserMapper.class]: Invalid value type for attribute 'factoryBeanObjectType': java.lang.String



============================
CONDITIONS EVALUATION REPORT
============================


Positive matches:
-----------------

   AopAutoConfiguration matched:
      - @ConditionalOnProperty (spring.aop.auto=true) matched (OnPropertyCondition)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值