SpringBoot3匹配Mybatis3的错误与解决方案

 更新时间:2025年08月16日 10:25:32   作者:RR1335  
文章指出SpringBoot3与MyBatis3兼容性问题,因未更新MyBatis-Plus依赖至SpringBoot3专用坐标,导致类冲突,解决方案是替换pom中的依赖为`mybatis-plus-spring-boot3-starter:3.5.12`,并排除旧版本核心库,确保版本一致性

SpringBoot3匹配Mybatis3的错误与解决

mybatis-plus在pom文件中的出错

提到了 pom 文件的错误。

mybatis在SpringBoot3

提供了一个新的 坐标:

<!-- https://mvnrepository.com/artifact/com.baomidou/mybatis-plus-spring-boot3-starter -->
<dependency>
    <groupId>com.baomidou</groupId>
    <artifactId>mybatis-plus-spring-boot3-starter</artifactId>
    <version>3.5.12</version>
</dependency>

如果没有个更新到新坐标

一样会出错。

Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.annotation.ConflictingBeanDefinitionException: Annotation-specified bean name 'compatibleSet' for bean class [com.baomidou.mybatisplus.extension.spi.CompatibleSet] conflicts with existing, non-compatible bean definition of same name and class [com.baomidou.mybatisplus.core.spi.CompatibleSet]


org.springframework.context.annotation.ConflictingBeanDefinitionException: Annotation-specified bean name 'compatibleSet' for bean class [com.baomidou.mybatisplus.extension.spi.CompatibleSet] conflicts with existing, non-compatible bean definition of same name and class [com.baomidou.mybatisplus.core.spi.CompatibleSet]
    at org.springframework.context.annotation.ClassPathBeanDefinitionScanner.checkCandidate(ClassPathBeanDefinitionScanner.java:361) ~[spring-context-6.2.8.jar:6.2.8]
    at org.mybatis.spring.mapper.ClassPathMapperScanner.checkCandidate(ClassPathMapperScanner.java:322) ~[mybatis-spring-2.1.2.jar:2.1.2]
    at org.springframework.context.annotation.ClassPathBeanDefinitionScanner.doScan(ClassPathBeanDefinitionScanner.java:288) ~[spring-context-6.2.8.jar:6.2.8]
    at org.mybatis.spring.mapper.ClassPathMapperScanner.doScan(ClassPathMapperScanner.java:209) ~[mybatis-spring-2.1.2.jar:2.1.2]
    at org.springframework.context.annotation.ClassPathBeanDefinitionScanner.scan(ClassPathBeanDefinitionScanner.java:255) ~[spring-context-6.2.8.jar:6.2.8]
    at org.mybatis.spring.mapper.MapperScannerConfigurer.postProcessBeanDefinitionRegistry(MapperScannerConfigurer.java:381) ~[mybatis-spring-2.1.2.jar:2.1.2]
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:349) ~[spring-context-6.2.8.jar:6.2.8]
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:148) ~[spring-context-6.2.8.jar:6.2.8]
    at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:791) ~[spring-context-6.2.8.jar:6.2.8]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:609) ~[spring-context-6.2.8.jar:6.2.8]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146) ~[spring-boot-3.5.3.jar:3.5.3]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:752) ~[spring-boot-3.5.3.jar:3.5.3]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:439) ~[spring-boot-3.5.3.jar:3.5.3]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:318) ~[spring-boot-3.5.3.jar:3.5.3]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1361) ~[spring-boot-3.5.3.jar:3.5.3]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1350) ~[spring-boot-3.5.3.jar:3.5.3]
    at com.wucaimu.WuCaiMuApplicationStart.main(WuCaiMuApplicationStart.java:19) ~[classes/:na]

总结

以上为个人经验,希望能给大家一个参考,也希望大家多多支持脚本之家。

相关文章

  • java.text.DecimalFormat用法详解

    java.text.DecimalFormat用法详解

    这篇文章主要为大家详细介绍了java.text.DecimalFormat用法,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
    2018-03-03
  • 从dubbo源码分析qos-server端口冲突问题及解决

    从dubbo源码分析qos-server端口冲突问题及解决

    这篇文章主要介绍了从dubbo源码分析qos-server端口冲突问题及解决方案,具有很好的参考价值,希望对大家有所帮助。如有错误或未考虑完全的地方,望不吝赐教
    2023-02-02
  • Java原子类中的AtomicInteger类详解

    Java原子类中的AtomicInteger类详解

    这篇文章主要介绍了Java原子类中的AtomicInteger类详解,原子类可以保证对"变量"操作的,原子性、有序性、可见性,我们可以通过AtomicInteger类,来看看它们是怎样工作的,需要的朋友可以参考下
    2023-10-10
  • SpringAOP中的通知Advice解析

    SpringAOP中的通知Advice解析

    这篇文章主要介绍了SpringAOP中的通知Advice解析,AOP 中的通知是基于连接点业务逻辑的一种增强,Spring AOP 可以基于 XML 方式和基于注解方式定义,只是写法不同,这里只使用注解的方式来讲解通知的详细用法,需要的朋友可以参考下
    2023-09-09
  • 如何通过Kaptcha在Web页面生成验证码

    如何通过Kaptcha在Web页面生成验证码

    这篇文章主要介绍了如何通过Kaptcha在Web页面生成验证码,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下
    2020-10-10
  • Mybatis模糊查询及自动映射实现详解

    Mybatis模糊查询及自动映射实现详解

    这篇文章主要介绍了Mybatis模糊查询及自动映射实现详解,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下
    2020-02-02
  • 解决rocketmq-client日志保存路径的问题

    解决rocketmq-client日志保存路径的问题

    这篇文章主要介绍了解决rocketmq-client日志保存路径的问题,具有很好的参考价值,希望对大家有所帮助。如有错误或未考虑完全的地方,望不吝赐教
    2021-07-07
  • java设计模式之装饰器模式(Decorator)

    java设计模式之装饰器模式(Decorator)

    这篇文章主要为大家详细介绍了java设计模式之装饰器模式Decorator,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
    2017-01-01
  • 详解关于IntelliJ IDEA中Schedule for Addition 的问题

    详解关于IntelliJ IDEA中Schedule for Addition 的问题

    本篇文章主要介绍了详解关于 IntelliJ IDEA 中 Schedule for Addition 的问题,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
    2017-12-12
  • Spring Boot ActiveMQ如何设置访问密码

    Spring Boot ActiveMQ如何设置访问密码

    这篇文章主要介绍了Spring Boot ActiveMQ如何设置访问密码,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下
    2020-07-07

最新评论