SpringBoot3.2.0整合MyBatis-plus的相關問題及處理方法

SpringBoot3.2.0整合MyBatis-plus的相關問題

文章目錄

  • SpringBoot3.2.0整合MyBatis-plus的相關問題
  • 1. build.gradle
  • 2. mybatis-plus整合問題
    • 1. 錯誤描述
    • 2. 問題分析及解決
      • 1. 原因分析
      • 2. 解決方式

Springboot3.2.0 GA版發布于 2023-11-24

環境:SpringBoot3.2.0+Gradle8.x+Java17

1. build.gradle

plugins {id 'java'id 'org.springframework.boot' version '3.2.0'
}group = 'com.yuan'
version = '1.0.0'
java {sourceCompatibility = '17'
}configurations {compileOnly {extendsFrom annotationProcessor}
}repositories {mavenLocal()mavenCentral()
}dependencies {//....implementation 'org.springframework.boot:spring-boot-starter-actuator'implementation 'com.baomidou:mybatis-plus-boot-starter:3.5.4.1'
}tasks.named('test') {outputs.dir snippetsDiruseJUnitPlatform()
}tasks.named('asciidoctor') {inputs.dir snippetsDirdependsOn test
}hibernate {enhancement {enableAssociationManagement = true}
}

2. mybatis-plus整合問題

1. 錯誤描述

升級后出現java.lang.IllegalArgumentException: Invalid value type for attribute 'factoryBeanObjectType': java.lang.String 問題,如下

  .   ____          _            __ _ _/\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \\\/  ___)| |_)| | | | | || (_| |  ) ) ) )'  |____| .__|_| |_|_| |_\__, | / / / /=========|_|==============|___/=/_/_/_/:: Spring Boot ::                (v3.2.0)2023-11-24 16:34:46.822 [background-preinit] INFO  org.hibernate.validator.internal.util.Version:21 - HV000001: Hibernate Validator 8.0.1.Final
2023-11-24 16:34:46.862 [restartedMain] INFO  com.yuan.YuanBoot3AdminApplication:50 - Starting YuanBoot3AdminApplication using Java 17.0.7 with PID 33080 (E:\myGradleProjects\springboot3\yuan-boot3-vue3\yuan-boot3-admin\build\classes\java\main started by jinshengyuan in E:\myGradleProjects\springboot3)
2023-11-24 16:34:46.863 [restartedMain] INFO  com.yuan.YuanBoot3AdminApplication:659 - The following 3 profiles are active: "myhome", "api_docs", "flyway"
2023-11-24 16:34:46.899 [restartedMain] INFO  o.s.b.d.env.DevToolsPropertyDefaultsPostProcessor:252 - Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2023-11-24 16:34:46.900 [restartedMain] INFO  o.s.b.d.env.DevToolsPropertyDefaultsPostProcessor:252 - For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2023-11-24 16:34:47.938 [restartedMain] INFO  o.s.d.r.config.RepositoryConfigurationDelegate:292 - Multiple Spring Data modules found, entering strict repository configuration mode
2023-11-24 16:34:47.940 [restartedMain] INFO  o.s.d.r.config.RepositoryConfigurationDelegate:139 - Bootstrapping Spring Data Redis repositories in DEFAULT mode.
2023-11-24 16:34:47.974 [restartedMain] INFO  o.s.d.r.config.RepositoryConfigurationDelegate:208 - Finished Spring Data repository scanning in 24 ms. Found 0 Redis repository interfaces.
2023-11-24 16:34:48.067 [restartedMain] WARN  o.s.b.w.s.c.AnnotationConfigServletWebServerApplicationContext:624 - Exception encountered during context initialization - cancelling refresh attempt: java.lang.IllegalArgumentException: Invalid value type for attribute 'factoryBeanObjectType': java.lang.String
2023-11-24 16:34:48.078 [restartedMain] INFO  o.s.b.a.logging.ConditionEvaluationReportLogger:82 - Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled.
2023-11-24 16:34:48.091 [restartedMain] ERROR org.springframework.boot.SpringApplication:839 - Application run failed
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.yuan.YuanBoot3AdminApplication.main(YuanBoot3AdminApplication.java:24)at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)at java.base/java.lang.reflect.Method.invoke(Method.java:568)at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:50)Process finished with exit code 0

2. 問題分析及解決

1. 原因分析

經排查發現引入的mybaits-plus版本為3.5.4.1,依賴spring與mybatis整合的版本為org.mybatis:mybatis-spring:2.1.1,

所以會導致Invalid value type for attribute 'factoryBeanObjectType': java.lang.String的問題

2. 解決方式

有兩種解決方式

  1. 升級Mybatisplus的版本到最高版本,如implementation 'com.baomidou:mybatis-plus-generator:3.5.5'
  2. 還是用3.5.4.1版本,需要在build.gradle中引入mybatis-spring的高版本,如下mybatis-spring:3.0.3
plugins {id 'java'id 'org.springframework.boot' version '3.2.0'
}group = 'com.yuan'
version = '1.0.0'
java {sourceCompatibility = '17'
}configurations {compileOnly {extendsFrom annotationProcessor}
}repositories {mavenLocal()mavenCentral()
}dependencies {//....implementation 'org.springframework.boot:spring-boot-starter-actuator'implementation 'com.baomidou:mybatis-plus-boot-starter:3.5.4.1'// https://mvnrepository.com/artifact/org.mybatis/mybatis-spring//解決MyBaits-Plus依賴中spring-mybatis:2.1.1版本報`Invalid value type for attribute 'factoryBeanObjectType': java.lang.String`的問題implementation 'org.mybatis:mybatis-spring:3.0.3'}tasks.named('test') {outputs.dir snippetsDiruseJUnitPlatform()
}tasks.named('asciidoctor') {inputs.dir snippetsDirdependsOn test
}hibernate {enhancement {enableAssociationManagement = true}
}

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/714849.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/714849.shtml
英文地址,請注明出處:http://en.pswp.cn/news/714849.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

【蛀牙】日常生活如何正確護理牙齒?刷牙、洗牙、補牙

程序員生活指南之 【蛀牙】日常生活如何正確護理牙齒?刷牙、洗牙、補牙 文章目錄 一、日常如何清洗牙齒?——刷牙與洗牙1、牙齒污垢1.1 牙菌斑1.2 軟垢1.3 牙結石1.4 牙齦出血 2、如何刷牙2.1 關于時間2.2 各種工具2.3 巴氏刷牙法 二、定期進行洗牙3、如…

題目 1076: 內部收益率

題目描述: 在金融中,我們有時會用內部收益率IRR來評價項目的投資財務效益,它等于使得投資凈現值NPV等于0的貼現率。換句話說,給定項目的期數T、初始現金流CF0和項目各期的現金流CF1, CF2, ...,CFT,IRR是下面方程的解&…

RISC-V特權架構 - 特權模式與指令

RV32/64 特權架構 - 特權模式與指令 1 特權模式2 特權指令2.1 mret(從機器模式返回到先前的模式)2.2 sret(從監管模式返回到先前的模式)2.3 wfi(等待中斷)2.4 sfence.vma(內存屏障) …

SpringBoot+Vue+MySQL:裝修管理新架構探索

??計算機畢業編程指導師 ??個人介紹:自己非常喜歡研究技術問題!專業做Java、Python、微信小程序、安卓、大數據、爬蟲、Golang、大屏等實戰項目。 ??實戰項目:有源碼或者技術上的問題歡迎在評論區一起討論交流! ?? Java、…

FPGA開源項目分享——2D N-Body重力模擬器

?導語 今天繼續康奈爾大學FPGA 課程ECE 5760的典型案例分享——2D N-Body重力模擬器。 (更多其他案例請參考網站: Final Projects ECE 5760) 1. 項目概述 項目網址 Grav Sim 項目說明 該項目的目標是創建一個用DE1-SOC進行硬件加速的2…

Java面試技巧

一、面試前準備 復習基礎知識:深入理解Java核心概念,如JVM、JDK、JRE等。熟悉Java基本語法、面向對象編程、異常處理、集合類、IO流等。同時,對Java的新特性,如Lambda表達式、Stream API等也要有所了解。強化算法和數據結構&…

簡易內存池2 - 華為OD統一考試(C卷)

OD統一考試(C卷) 分值: 200分 題解: Java / Python / C 題目描述 請實現一個簡易內存池,根據請求命令完成內存分配和釋放。 內存池支持兩種操作命令,REQUEST和RELEASE,其格式為: REQUEST請求的內存大小 …

Redis 【1】—— 安裝 與 配置

Redis 【1】—— 安裝 與 配置 一、安裝 與 配置(一)使用 yum 安裝(二)創建符號鏈接1. 軟鏈接2. 相關指令 (三)修改配置文件(四)Redis 的啟停 一、安裝 與 配置 (一&…

Java的強引用、軟引用、弱引用和虛引用詳解。

Java的強引用、軟引用、弱引用和虛引用 1. 強引用2. 軟引用3. 弱引用4. 虛引用 總結 Java的強引用、軟引用、弱引用和虛引用可以用來標識GC時判斷對象是否達到回收的條件,下面結合Java代碼看看這四類引用吧。 1. 強引用 是最普通的引用方式,通過new關鍵…

外貿業務員沒客戶的7大原因+解決辦法!

業務員沒有客戶,就是無源之水,無本之木,這自然也就沒有業績。那些吃空餉的業務員,遲早會拖垮公司。所以不管是什么原因導致的業務員沒客戶,都要一一查驗清楚。七個業務員沒有客戶的原因,七種對策&#xff0…

華為數通方向HCIP-DataCom H12-821題庫(多選題:21-40)

第21題 管理員在配置 VRRP 時,下面哪些不是必須配置的? A.搶占模式 B.搶占延時 C.虛擬IP 地址 D.虛擬路由器的優先級 【參考答案】ABD 【答案解析】 VRRP的作用之一是提供一個虛擬的IP地址,用作默認網關,用來實現冗余和故障轉移。因此,配置虛擬IP地址是必須的。華為設備vr…

hcip交換

交換機功能 無限的傳輸距離——識別,重寫電信號(幀)保證信息完整徹底解決了沖突二層單播——MAC地址表提高端口密度 單播地址:MAC地址第一個字節第8位為0 組播地址:MAC地址第一個字節第8位為1 廣播地址:全1…

滲透測試靶場環境搭建

1.DVWA靶場 DVWA(Damn Vulnerable Web Application)是一個用來進行安全脆弱性鑒定的PHP/MySQL Web應用,包含了OWASP TOP10的所有攻擊漏洞的練習環境,旨在為安全專業人員測試自己的專業技能和工具提供合法的環境,同時…

Mybatis批量更新對象數據的兩種方法

說明:遇到一次需要批量修改對象的場景。傳遞一個對象集合,需要根據對象ID批量修改數據庫數據,使用的是MyBatis框架。查了一些資料,總結出兩種實現方式。 創建Demo 首先,創建一個簡單的Demo; &#xff08…

SpringBoot+Jwt+Redis

大致流程: 參照: 史上最全面的基于JWT token登陸驗證_完整的基于jwt的登陸認證-CSDN博客 springboot整合JWTRedis_springboot jwt redis-CSDN博客

鴻蒙Harmony應用開發—ArkTS聲明式開發(通用屬性:浮層)

設置組件的遮罩文本。 說明: 從API Version 7開始支持。后續版本如有新增內容,則采用上角標單獨標記該內容的起始版本。 overlay overlay(value: string | CustomBuilder, options?: { align?: Alignment; offset?: { x?: number; y?: number } })…

劍指offer面試題28:對稱的二叉樹

#試題28:對稱的二叉樹 題目: 請設計一個函數判斷一棵二叉樹是否 軸對稱 。 示例 1: 輸入:root [6,7,7,8,9,9,8] 輸出:true 解釋:從圖中可看出樹是軸對稱的。示例 2: 輸入:root …

【合宙ESP32C3 Arduino開發】第四篇:TFT_eSPI 驅動 合宙Air101 ST7735 LCD 顯示普通時鐘,模塊化編程

忘記過去,超越自己 ?? 博客主頁 單片機菜鳥哥,一個野生非專業硬件IOT愛好者 ???? 本篇創建時間 2024-03-02???? 本篇更新時間 2024-03-02??🎉 歡迎關注 🔎點贊 👍收藏 ??留言📝🙏…

白話大模型② | 如何提升AI分析的準確性?

白話大模型系列共六篇文章,將通俗易懂的解讀大模型相關的專業術語。本文為第二篇:如何提升AI分析的準確性? 作者:星環科技 人工智能產品部 面對AI分析落地時的數量化、準確性、泛化性等問題,讓我們稍微深入了解下當前…

pycharm專業版本的安裝

一 、到官網下載對應的pycharm安裝包 也可以把安裝軟件(用物理機下載到共享文件夾) 然后進入Ubuntu系統把下載大的安裝包剪貼到目標路徑 1 在ubuntu中創建一個用來存放pycharm安裝包的文件夾 rootzmq-virtual-machine:/home/zmq/Desktop# mkdir pycha…