baomidou / mybatis-plus

An powerful enhanced toolkit of MyBatis for simplify development
https://baomidou.com
Apache License 2.0
16.42k stars 4.31k forks source link

mybatis-plus 3.5.5+pagehelper 2.1.0 startup exception. #5881

Closed 1527430 closed 10 months ago

1527430 commented 10 months ago

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

mybatis-plus 3.5.5

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

pagehelper 2.1.0 spring boot 3.2.0 open jdk 21

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

启动就出如下错误。

报错信息

15:30:42.367 traceId=[] spanId=[] [main] INFO c.r.WebApplication - [logStartupProfileInfo,659] - The following 1 profile is active: "dev" 15:30:44.222 traceId=[] spanId=[] [main] WARN o.s.b.w.s.c.AnnotationConfigServletWebServerApplicationContext - [refresh,624] - Exception encountered during context initialization - cancelling refresh attempt: java.lang.IllegalArgumentException: Invalid value type for attribute 'factoryBeanObjectType': java.lang.String 15:30:44.255 traceId=[] spanId=[] [main] ERROR o.s.b.SpringApplication - [reportFailure,839] - 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.ruoyi.WebApplication.main(WebApplication.java:23)

nieqiurong commented 10 months ago

检查项目依赖,或者提供工程.

pigeon2049 commented 10 months ago

jsqlparser冲突导致的

1527430 commented 10 months ago

Reference

大概率如此,mp中使用jsqlparser 4.6, 而pagehelper 2.1中已经使用了4.7。如果把pagehelper 降为 2.0,那么又会有找不到jsqlparser中的一个类的异常。 建议mp中引用的第三方jar都全面升级到最新稳定版。

ZhiQinIsZhen commented 10 months ago
        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-boot-starter</artifactId>
            <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</version>
        </dependency>

使用最新的就好了

1527430 commented 10 months ago
        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-boot-starter</artifactId>
            <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</version>
        </dependency>

使用最新的就好了

这种方式我用过,也是不行啊。而且,3.5.5的文档里说道已经使用了mybatis-spring 3.0.3。

itranlin commented 10 months ago

你应该是使用 spring-boot3单独的版本

<dependency>
    <groupId>com.baomidou</groupId>
    <artifactId>mybatis-plus-spring-boot3-starter</artifactId>
</dependency>
image
1527430 commented 10 months ago
mybatis-plus-spring-boot3-starter

使用这个mybatis-plus-spring-boot3-starter,依然不支持pagehelper 2.1,只支持2.0。不过spring boot 可以升级到 3.2.1。

nieqiurong commented 10 months ago

5872

brucelpt commented 10 months ago
        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-boot-starter</artifactId>
            <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</version>
        </dependency>

使用最新的就好了

我的项目换了这个就可以了,但是我的报错和上面的老哥不一样,我的是: java.lang.IllegalArgumentException: Invalid value type for attribute 'factoryBeanObjectType': java.lang.String

qichhhhh commented 9 months ago

我也遇到这个问题了,楼主解决了吗?