Invalid default: public abstract java.lang.Class org.mybatis.spring.annotation.MapperScan.factoryBea

文章描述了在SpringBoot应用中整合MyBatis时遇到的@MapperScan注解错误,原因是使用了已废弃的factoryBean()方法。解决方案包括更新到兼容的库版本,如SpringBoot2.5.6和mybatis-spring-boot-starter2.3.1,以及确保@MapperScan配置正确无误。

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

SpringBoot 整合mybatis 报错

Invalid default: public abstract java.lang.Class org.mybatis.spring.annotation.MapperScan.factoryBea

这个错误通常发生在使用 @MapperScan 注解配置 MyBatis 扫描时出现问题。根据您提供的错误信息,似乎是由于对 @MapperScan 注解中的 factoryBean() 方法使用了无效的默认值。

在最新版本的 Spring Boot 和 MyBatis 中,@MapperScan 注解的 factoryBean() 方法已被废弃,并且不再需要提供默认值。您可以尝试更新相关依赖的版本,确保使用的是兼容的版本。

如果您的 Spring Boot 版本较旧,可能需要考虑升级到最新版本以解决此问题。同时,确保您使用的 MyBatis 和 MyBatis-Spring 版本与您的 Spring Boot 版本兼容。

另外,还请确保 @MapperScan 注解的位置和配置都正确无误。它通常位于主应用程序类上方,并指定正确的 Mapper 接口扫描路径。

如果问题仍然存在,请提供更多相关的代码和配置信息,以便更详细地分析和帮助您解决该问题。

以下是我的springboot 和mybatis 的版本对应关系,解决了该问题

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.5.6</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

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

        <dependency>
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>mybatis-spring-boot-starter-test</artifactId>
            <version>2.3.1</version>
            <scope>test</scope>
        </dependency>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Edison-XX

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值