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

3.5.4 using mybatis-plus-spring-boot3-starter

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

我们注意到mybatis社区也有同样的issue,虽然关闭了,但是没有任何提示是否进行了修复。 https://github.com/mybatis/spring-boot-starter/issues/881

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

报错信息

java.lang.IllegalArgumentException: Invalid value type for attribute 'factoryBeanObjectType': java.lang.String
    at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getTypeForFactoryBeanFromAttributes(FactoryBeanRegistrySupport.java:86) ~[spring-beans-6.1.0-RC1.jar:6.1.0-RC1]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getTypeForFactoryBean(AbstractAutowireCapableBeanFactory.java:838) ~[spring-beans-6.1.0-RC1.jar:6.1.0-RC1]
    at org.springframework.beans.factory.support.AbstractBeanFactory.isTypeMatch(AbstractBeanFactory.java:620) ~[spring-beans-6.1.0-RC1.jar:6.1.0-RC1]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doGetBeanNamesForType(DefaultListableBeanFactory.java:573) ~[spring-beans-6.1.0-RC1.jar:6.1.0-RC1]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:532) ~[spring-beans-6.1.0-RC1.jar:6.1.0-RC1]
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:136) ~[spring-context-6.1.0-RC1.jar:6.1.0-RC1]
    at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:776) ~[spring-context-6.1.0-RC1.jar:6.1.0-RC1]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:597) ~[spring-context-6.1.0-RC1.jar:6.1.0-RC1]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146) ~[spring-boot-3.2.0-RC1.jar:3.2.0-RC1]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:748) ~[spring-boot-3.2.0-RC1.jar:3.2.0-RC1]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:450) ~[spring-boot-3.2.0-RC1.jar:3.2.0-RC1]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:322) ~[spring-boot-3.2.0-RC1.jar:3.2.0-RC1]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1336) ~[spring-boot-3.2.0-RC1.jar:3.2.0-RC1]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1325) ~[spring-boot-3.2.0-RC1.jar:3.2.0-RC1]
    at com.quanyu.technews.TechnewsApplicationKt.main(TechnewsApplication.kt:13) ~[main/:na]

我不方便提供demo,因为涉及个人的项目,不过我是从Spring boot 2.7.15升级遇到的问题。然后我尝试降级到spring-boot 3.1.5就一切正常了。使用的JDK是21。

Comment From: nieqiurong

官网说了只支持3.1.x , 3.2.x的springboot还在开发中.

MyBatis-Plus 使用Spring boot 3.2.0-RC1配合配合mybatis-plus 3.5.4的问题

Comment From: techwn

官网说了只支持3.1.x , 3.2.x的springboot还在开发中.

MyBatis-Plus 使用Spring boot 3.2.0-RC1配合配合mybatis-plus 3.5.4的问题

多谢,根据这个提醒,我找到了官方文档:http://mybatis.org/spring-boot-starter/mybatis-spring-boot-autoconfigure/

Comment From: lzysuqianqiu

https://github.com/mybatis/spring-boot-starter/issues/895#issue-1957030318

Comment From: lzysuqianqiu

https://github.com/mybatis/spring-boot-starter/issues/896#issue-1957043928

Comment From: nieqiurong

尝试下个版本支持SpringBoot3.2.x

Comment From: HavocZhang

我看mybatis-spring-boot已经升级了快照

<dependency>
  <groupId>org.mybatis.spring.boot</groupId>
   <artifactId>mybatis-spring-boot-starter</artifactId>
   <version>3.0.3-SNAPSHOT</version>
</dependency>

但是为什么还是报错 Invalid value type for attribute 'factoryBeanObjectType': java.lang.String https://github.com/mybatis/spring-boot-starter/issues/896

Comment From: pigeon2049

写了篇博客 详见https://edwardzhan.hashnode.dev/project-loom

解决方法 启用snapshot库

 <repositories>
        <repository>
            <id>spring-milestones</id>
            <name>Spring Milestones</name>
            <url>https://repo.spring.io/milestone</url>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
        <repository>
            <id>spring-snapshots</id>
            <name>Spring Snapshots</name>
            <url>https://repo.spring.io/snapshot</url>
            <releases>
                <enabled>true</enabled>
            </releases>
        </repository>
        <repository>
            <id>snapshots</id>
            <url>https://oss.sonatype.org/content/repositories/snapshots/</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
    </repositories>
    <pluginRepositories>
        <pluginRepository>
            <id>spring-milestones</id>
            <name>Spring Milestones</name>
            <url>https://repo.spring.io/milestone</url>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </pluginRepository>
        <pluginRepository>
            <id>spring-snapshots</id>
            <name>Spring Snapshots</name>
            <url>https://repo.spring.io/snapshot</url>
            <releases>
                <enabled>true</enabled>
            </releases>
        </pluginRepository>
    </pluginRepositories>

升级mybatis-spring版本

 <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-boot-starter</artifactId>
            <version>3.5.5-SNAPSHOT</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-SNAPSHOT</version>
        </dependency>

打包后测试运行正常

Comment From: techwn

mybatis-spring 3.0.3已经正式发布了 https://mvnrepository.com/artifact/org.mybatis/mybatis-spring

Comment From: nieqiurong

已发布3.5.5-SNAPSHOT

Comment From: nieqiurong

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