?? 作者主頁: 有來技術(shù)
?? 開源項(xiàng)目: youlai-mall ?? vue3-element-admin ?? youlai-boot
?? 倉(cāng)庫(kù)主頁: Gitee ?? Github ?? GitCode
?? 歡迎點(diǎn)贊 ?? 收藏 ?留言 ?? 如有錯(cuò)誤敬請(qǐng)糾正!
問題描述
youlai-boot 升級(jí) Spring Boot 3.2 版本項(xiàng)目啟動(dòng)報(bào)錯(cuò):
java.lang.IllegalArgumentException: Invalid value type for attribute 'factoryBeanObjectType': java.lang.String
報(bào)錯(cuò)截圖如下:
原因分析
mybatis-spring
官方 ISSUE: https://github.com/mybatis/spring/issues/855
項(xiàng)目中使用 mybatis-plus-boot-starter
當(dāng)前最新版本 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 類型會(huì)拋出 IllegalArgumentException
異常。
此時(shí)因?yàn)?factoryBeanObjectType
是 String 類型,不符合條件而拋出異常。
解決方案
mybatis-spring 官方 ISSUE 說明在 3.0.3 版本修復(fù)此問題
確實(shí) 3.0.3 版本已出
Mybatis-Plus 官方 ISSUE#5808 下面也說明會(huì)在 3.5.5 版本升級(jí) mybatis-spring 依賴修復(fù)此問題,但截止到目前只有快照版本 3.5.5-SNAPSHOT
。
所以目前好一點(diǎn)的方案就是手動(dòng)升級(jí) 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>
修改后再重新啟動(dòng)ok文章來源:http://www.zghlxwxcb.cn/news/detail-774872.html
文章來源地址http://www.zghlxwxcb.cn/news/detail-774872.html
開源項(xiàng)目
- SpringCloud + Vue3 微服務(wù)商城
Github | Gitee | |
---|---|---|
后端 | youlai-mall ?? | youlai-mall ?? |
前端 | mall-admin?? | mall-admin ?? |
移動(dòng)端 | mall-app ?? | mall-app ?? |
- SpringBoot 3+ Vue3 單體權(quán)限管理系統(tǒng)
Github | Gitee | |
---|---|---|
后端 | youlai-boot ?? | youlai-boot ?? |
前端 | vue3-element-admin ?? | vue3-element-admin ?? |
到了這里,關(guān)于Spring Boot 升級(jí) 3.2 報(bào)錯(cuò) Invalid value type for attribute ‘factoryBeanObjectType‘: java.lang.String的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!