SpringBoot升級3.2報錯Invalid value type for attribute ‘factoryBeanObjectType‘: java.lang.String的解決方案
問題描述
youlai-boot 升級 Spring Boot 3.2 版本項目啟動報錯:
java.lang.IllegalArgumentException: Invalid value type for attribute 'factoryBeanObjectType': java.lang.String
報錯截圖如下:

原因分析
mybatis-spring 官方 ISSUE: https://github.com/mybatis/spring/issues/855
項目中使用 mybatis-plus-boot-starter 當前最新版本 3.5.4.1 ,其中依賴的 mybatis-spring 版本為 2.1.1

在 mybatis-spring 2.1.1 版本的 ClassPathMapperScanner#processBeanDefinitions 方法里將 BeanClassName 賦值給 String 變量

并將 beanClassName 賦值給 factoryBeanObjectType

但是在 Spring Boot 3.2 版本中FactoryBeanRegistrySupport#getTypeForFactoryBeanFromAttributes方法已變更,如果 factoryBeanObjectType 不是 ResolvableType 或 Class 類型會拋出 IllegalArgumentException 異常。
此時因為 factoryBeanObjectType 是 String 類型,不符合條件而拋出異常。

解決方案
mybatis-spring 官方 ISSUE 說明在 3.0.3 版本修復此問題

確實 3.0.3 版本已出

Mybatis-Plus 官方 ISSUE#5808 下面也說明會在 3.5.5 版本升級 mybatis-spring 依賴修復此問題,但截止到目前只有快照版本 3.5.5-SNAPSHOT 。
所以目前好一點的方案就是手動升級 mybatis-spring 版本為 3.0.3
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.5.4.1</version>
<exclusions>
<exclusion>
<artifactId>mybatis-spring</artifactId>
<groupId>org.mybatis</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>3.0.3</version>
</dependency>
修改后再重新啟動ok

以上就是SpringBoot升級3.2報錯Invalid value type for attribute ‘factoryBeanObjectType‘: java.lang.String的解決方案的詳細內(nèi)容,更多關于SpringBoot升級3.2報錯的資料請關注腳本之家其它相關文章!
相關文章
如何通過java實現(xiàn)highcharts導出圖片至excel
這篇文章主要介紹了如何通過java實現(xiàn)highcharts導出圖片至excel。文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,下面我們就來一起學習一下吧2019-06-06
如何解決getReader() has already been called&
這篇文章主要介紹了如何解決getReader() has already been called for this request問題,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教2024-05-05
SpringSecurity Jwt Token 自動刷新的實現(xiàn)
這篇文章主要介紹了SpringSecurity Jwt Token 自動刷新的實現(xiàn),文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2020-06-06

