当前位置: 首页 > news >正文

SpringBoot3整合Mybatis-Plus与PageHelper包冲突解决

😊 @ 作者: 一恍过去
💖 @ 主页: https://blog.csdn.net/zhuocailing3390
🎊 @ 社区: Java技术栈交流
🎉 @ 主题: SpringBoot3整合Mybatis-Plus与PageHelper包冲突解决
⏱️ @ 创作时间: 2024年03月15日

在这里插入图片描述

目录

    • 前言
    • 1、SpringBoot3在整合Mybatis-Plus与PageHelper的同时会出现,包冲突问题
    • 2、factoryBeanObjectType错误
    • 3、完整pom配置

前言

在将项目由SpringBoot2.x升级为SpringBoot3.2.0时,对Mybatis-Plus及Pagehelper同时进行了升级,升级过程组出现了包冲突以及factoryBeanObjectType异常的情况,下面是一个总结!

1、SpringBoot3在整合Mybatis-Plus与PageHelper的同时会出现,包冲突问题

pagehelper-spring-boot-starter包中会引入mybatis-spring-boot-starter包,会与mybatis-plus-boot-starter出现冲突:

***************************
APPLICATION FAILED TO START
***************************Description:An attempt was made to call a method that does not exist. The attempt was made from the following location:com.baomidou.mybatisplus.autoconfigure.MybatisPlusProperties$CoreConfiguration.applyTo(MybatisPlusProperties.java:356)The following method did not exist:'void org.apache.ibatis.session.Configuration.setArgNameBasedConstructorAutoMapping(boolean)'The calling method's class, com.baomidou.mybatisplus.autoconfigure.MybatisPlusProperties$CoreConfiguration, was loaded from the following location:jar:file:/D:/m2/com/baomidou/mybatis-plus-spring-boot-autoconfigure/3.5.4.1/mybatis-plus-spring-boot-autoconfigure-3.5.4.1.jar!/com/baomidou/mybatisplus/autoconfigure/MybatisPlusProperties$CoreConfiguration.classThe called method's class, org.apache.ibatis.session.Configuration, is available from the following locations:jar:file:/D:/m2/org/mybatis/mybatis/3.5.9/mybatis-3.5.9.jar!/org/apache/ibatis/session/Configuration.classThe called method's class hierarchy was loaded from the following locations:org.apache.ibatis.session.Configuration: file:/D:/m2/org/mybatis/mybatis/3.5.9/mybatis-3.5.9.jarAction:Correct the classpath of your application so that it contains compatible versions of the classes com.baomidou.mybatisplus.autoconfigure.MybatisPlusProperties$CoreConfiguration and org.apache.ibatis.session.Configuration

解决包冲突:
需要排除mybatis-spring-boot-starter

<dependency><groupId>com.github.pagehelper</groupId><artifactId>pagehelper-spring-boot-starter</artifactId><version>1.4.5</version><exclusions><exclusion><groupId>org.mybatis.spring.boot</groupId><artifactId>mybatis-spring-boot-starter</artifactId></exclusion></exclusions></dependency>

2、factoryBeanObjectType错误

出现java.lang.IllegalArgumentException: Invalid value type for attribute 'factoryBeanObjectType': java.lang.String异常信息

java.lang.IllegalArgumentException: Invalid value type for attribute 'factoryBeanObjectType': java.lang.Stringat org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getTypeForFactoryBeanFromAttributes(FactoryBeanRegistrySupport.java:86)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getTypeForFactoryBean(AbstractAutowireCapableBeanFactory.java:838)at org.springframework.beans.factory.support.AbstractBeanFactory.isTypeMatch(AbstractBeanFactory.java:620)at org.springframework.beans.factory.support.DefaultListableBeanFactory.doGetBeanNamesForType(DefaultListableBeanFactory.java:573)at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:532)at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:138)at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:775)at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:597)at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146)at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:753)at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:455)at org.springframework.boot.SpringApplication.run(SpringApplication.java:323)at org.springframework.boot.SpringApplication.run(SpringApplication.java:1342)at org.springframework.boot.SpringApplication.run(SpringApplication.java:1331)at com.lhz.demo.DemoApplication.main(DemoApplication.java:10)

解决方案:
需要排除mybatis-plus-boot-startermybatis-spring,并且单独引入高版本的mybatis-spring

<dependency><groupId>com.baomidou</groupId><artifactId>mybatis-plus-boot-starter</artifactId><version>3.5.4.1</version><exclusions><exclusion><groupId>org.mybatis</groupId><artifactId>mybatis-spring</artifactId></exclusion></exclusions></dependency><dependency><groupId>org.mybatis</groupId><artifactId>mybatis-spring</artifactId><version>3.0.3</version></dependency>

3、完整pom配置

<dependency><groupId>com.github.pagehelper</groupId><artifactId>pagehelper-spring-boot-starter</artifactId><version>1.4.5</version><exclusions><exclusion><groupId>org.mybatis.spring.boot</groupId><artifactId>mybatis-spring-boot-starter</artifactId></exclusion></exclusions></dependency><dependency><groupId>com.baomidou</groupId><artifactId>mybatis-plus-boot-starter</artifactId><version>3.5.4.1</version><exclusions><exclusion><groupId>org.mybatis</groupId><artifactId>mybatis-spring</artifactId></exclusion></exclusions></dependency><dependency><groupId>org.mybatis</groupId><artifactId>mybatis-spring</artifactId><version>3.0.3</version></dependency>

在这里插入图片描述

http://www.lryc.cn/news/322680.html

相关文章:

  • MQTT Keep Alive机制
  • 基于springboot+vue的游戏交易系统
  • 高职(大专)结构化面试之答题思路
  • Python基础学习笔记(一)
  • 机器学习-可解释性机器学习:支持向量机与fastshap的可视化模型解析
  • 32.768K晶振X1A000141000300适用于无人驾驶汽车电子设备
  • 利用autodl服务器跑模型
  • 【微服务】分布式调度框架PowerJob使用详解
  • 一命通关广度优先遍历
  • 力扣4寻找两个正序数组的中位数
  • jmeter之常用函数-第六天
  • 原创!分解+集成思想新模型!VMD-CNN-BiGRU-Attention一键实现时间序列预测!以风速数据集为例
  • ab (Apache benchmark) - 压力/性能测试工具
  • 除了Confluence,有没有其他工具一样好用?
  • 查询表中数据(全列/特定列/表达式,where子句(比较/逻辑运算符),order by子句,limit筛选分页),mysql执行顺序
  • 【Linux】多线程概念 | POSIX线程库
  • Java Spring AOP代码3分钟快速入手
  • .NET开源快速、强大、免费的电子表格组件
  • docker一键部署若依前后端分离版本
  • Java项目开发之fastjson详解
  • 面试算法-62-盛最多水的容器
  • 【智能算法】海洋捕食者算法(MPA)原理及实现
  • 刷题DAY24 | LeetCode 77-组合
  • Spring Boot为什么默认使用CGLIB动态代理
  • 算法详解——Dijkstra算法
  • 利用GANs进行图像生成
  • Flutter-底部弹出框(Widget层级)
  • 聚焦两会:数字化再加速,VR全景助力制造业转型
  • 数据挖掘之关联规则
  • java:java.util.BitSet对象的Jackson序列化和反序列化实现