当前使用版本(必填,否则不予处理)

 <dependency>
        <groupId>com.baomidou</groupId>
        <artifactId>mybatis-plus-spring-boot3-starter</artifactId>
        <version>3.5.4.1</version>
    </dependency>

   <dependency>
        <groupId>com.baomidou</groupId>
        <artifactId>dynamic-datasource-spring-boot3-starter</artifactId>
        <version>4.2.0</version>
    </dependency>

该问题是如何引起的?(确定最新版也有问题再提!!!)

使用最新的springboot3.2.0版本,JAVA21

重现步骤(如果有就写完整)

springboot启动就报错

报错信息

`2023-11-24 14:58:28 INFO 22312 -- [ restartedMain] .s.b.a.l.ConditionEvaluationReportLogger :

Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled. 2023-11-24 14:58:28 ERROR 22312 -- [ restartedMain] o.s.boot.SpringApplication : Application run failed

java.lang.IllegalArgumentException: Invalid value type for attribute 'factoryBeanObjectType': java.lang.String at 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.laowang.springboot3template.Springboot3TemplateApplication.main(Springboot3TemplateApplication.java:23) at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) at java.base/java.lang.reflect.Method.invoke(Method.java:580) at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:50)

Process finished with exit code 0`

Comment From: C20171008S

需要升级mybatis-spring这个依赖到3.0.3,希望官方快点升级。

Comment From: yuxicun

MyBatis-Plus 最新的springboot3.2.0版本使用MP启动报错

Comment From: jinshengyuanok

//解决MyBaits-Plus依赖中spring-mybatis:2.1.1版本报Invalid value type for attribute 'factoryBeanObjectType': java.lang.String的问题 implementation 'org.mybatis:mybatis-spring:3.0.3'

Comment From: cloudlessa

同样遇到这个问题了,得升级mybatis-spring为3.0.3才行。或者springboot降级为3.1.x以下 springboot3.2.0重写了这个类FactoryBeanRegistrySupport的getTypeForFactoryBeanFromAttributes方法

ResolvableType getTypeForFactoryBeanFromAttributes(AttributeAccessor attributes) { Object attribute = attributes.getAttribute(FactoryBean.OBJECT_TYPE_ATTRIBUTE); if (attribute == null) { return ResolvableType.NONE; } if (attribute instanceof ResolvableType resolvableType) { return resolvableType; } if (attribute instanceof Class<?> clazz) { return ResolvableType.forClass(clazz); } throw new IllegalArgumentException("Invalid value type for attribute '" + FactoryBean.OBJECT_TYPE_ATTRIBUTE + "': " + attribute.getClass().getName()); }

springboot3.1.5:

ResolvableType getTypeForFactoryBeanFromAttributes(AttributeAccessor attributes) { Object attribute = attributes.getAttribute(FactoryBean.OBJECT_TYPE_ATTRIBUTE); if (attribute instanceof ResolvableType resolvableType) { return resolvableType; } if (attribute instanceof Class<?> clazz) { return ResolvableType.forClass(clazz); } return ResolvableType.NONE; }

之前的版本获取的attribute是个String类型,但是可以返回ResolvableType.NONE,就没报错了

Comment From: m1ngyuan

https://github.com/mybatis/spring/issues/855

Comment From: nieqiurong

5747