pagehelper / Mybatis-PageHelper

Mybatis通用分页插件
https://mybatis.io
MIT License
12.21k stars 3.13k forks source link

PageHelper6.1.0搭配jsqlparser4.5又出问题了 #814

Open LSL1618 opened 6 months ago

LSL1618 commented 6 months ago

异常模板

使用环境

SQL 解析错误

分页参数

PageHelper.startPage(1, 10);
xxMapper.select(model);

原 SQL

--与SQL无关

期望的结果:

--与SQL无关

完整异常信息

17-Apr-2024 16:41:39.506 严重 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR 部署 Web 应用程序 archive [\apache-tomcat-8.5.70\webapps\***.war] 时出错
    java.lang.IllegalStateException: 启动子级时出错
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:757)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:727)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:695)
        at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1016)
        at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1903)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:750)
    Caused by: org.apache.catalina.LifecycleException: 无法启动组件[StandardEngine[Catalina].StandardHost[localhost].StandardContext[/specimen]]
        at org.apache.catalina.util.LifecycleBase.handleSubClassException(LifecycleBase.java:440)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:198)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:753)
        ... 9 more
    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.github.pagehelper.autoconfigure.PageHelperAutoConfiguration': Invocation of init method failed; nested exception is java.lang.BootstrapMethodError: java.lang.IllegalAccessError: no such constructor: com.github.pagehelper.parser.defaults.DefaultCountSqlParser.<init>()void/newInvokeSpecial
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1794)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:594)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516)
        at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:324)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:897)
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:879)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:551)
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141)
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747)
        at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:405)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:315)
        at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.run(SpringBootServletInitializer.java:152)
        at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.createRootApplicationContext(SpringBootServletInitializer.java:132)
        at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.onStartup(SpringBootServletInitializer.java:92)
        at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:172)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5221)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
        ... 10 more
    Caused by: java.lang.BootstrapMethodError: java.lang.IllegalAccessError: no such constructor: com.github.pagehelper.parser.defaults.DefaultCountSqlParser.<init>()void/newInvokeSpecial
        at com.github.pagehelper.dialect.AbstractDialect.setProperties(AbstractDialect.java:57)
        at com.github.pagehelper.dialect.AbstractHelperDialect.setProperties(AbstractHelperDialect.java:233)
        at com.github.pagehelper.dialect.helper.SqlServerDialect.setProperties(SqlServerDialect.java:118)
        at com.github.pagehelper.page.PageAutoDialect.instanceDialect(PageAutoDialect.java:207)
        at com.github.pagehelper.page.PageAutoDialect.setProperties(PageAutoDialect.java:352)
        at com.github.pagehelper.PageHelper.setProperties(PageHelper.java:188)
        at com.github.pagehelper.PageInterceptor.setProperties(PageInterceptor.java:263)
        at com.github.pagehelper.autoconfigure.PageHelperAutoConfiguration.afterPropertiesSet(PageHelperAutoConfiguration.java:65)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1853)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1790)
        ... 29 more
    Caused by: java.lang.IllegalAccessError: no such constructor: com.github.pagehelper.parser.defaults.DefaultCountSqlParser.<init>()void/newInvokeSpecial
        at java.lang.invoke.MethodHandleNatives.linkMethodHandleConstant(MethodHandleNatives.java:483)
        ... 39 more
    Caused by: java.lang.VerifyError: Bad return type
Exception Details:
  Location:
    com/github/pagehelper/parser/defaults/DefaultCountSqlParser.sqlToCount(Lnet/sf/jsqlparser/statement/select/Select;Ljava/lang/String;)Lnet/sf/jsqlparser/statement/select/Select; @149: areturn
  Reason:
    Type 'net/sf/jsqlparser/statement/select/PlainSelect' (current frame, stack[0]) is not assignable to 'net/sf/jsqlparser/statement/select/Select' (from method signature)
  Current Frame:
    bci: @149
    flags: { }
    locals: { 'com/github/pagehelper/parser/defaults/DefaultCountSqlParser', 'net/sf/jsqlparser/statement/select/Select', 'java/lang/String', 'java/util/List', 'net/sf/jsqlparser/statement/select/PlainSelect', 'net/sf/jsqlparser/statement/select/ParenthesedSelect' }
    stack: { 'net/sf/jsqlparser/statement/select/PlainSelect' }
  Bytecode:
    0x0000000: bb00 2959 b700 2a4e 2dbb 002b 59bb 002c
    0x0000010: 59bb 001f 59b7 0020 122d b600 212c b600
    0x0000020: 2112 2eb6 0021 b600 22b7 002f b700 30b9
    0x0000030: 0031 0200 572b c100 1599 0018 2a2b c000
    0x0000040: 15b6 0032 9900 0d2b c000 152d b600 332b
    0x0000050: b0bb 0015 59b7 0034 3a04 bb00 3559 b700
    0x0000060: 363a 0519 052b b600 3719 05b2 0038 b600
    0x0000070: 3919 0419 05b6 003a 1904 2db6 0033 2bb6
    0x0000080: 0011 c600 1119 042b b600 11b6 003b 2b01
    0x0000090: b600 3c19 04b0                         
  Stackmap Table:
    append_frame(@81,Object[#169])
    append_frame(@147,Object[#170],Object[#171])

        at java.lang.invoke.MethodHandleNatives.resolve(Native Method)
        at java.lang.invoke.MemberName$Factory.resolve(MemberName.java:975)
        at java.lang.invoke.MemberName$Factory.resolveOrFail(MemberName.java:1000)
        at java.lang.invoke.MethodHandles$Lookup.resolveOrFail(MethodHandles.java:1394)
        at java.lang.invoke.MethodHandles$Lookup.linkMethodHandleConstant(MethodHandles.java:1750)
        at java.lang.invoke.MethodHandleNatives.linkMethodHandleConstant(MethodHandleNatives.java:477)
        ... 39 more
        <dependency>
            <groupId>com.github.pagehelper</groupId>
            <artifactId>pagehelper-spring-boot-starter</artifactId>
            <version>2.1.0</version>
            <exclusions>
                <exclusion>
                    <groupId>com.github.jsqlparser</groupId>
                    <artifactId>jsqlparser</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>com.github.pagehelper</groupId>
            <artifactId>sqlparser4.5</artifactId>
            <version>6.1.0</version>
        </dependency>

其他类型的错误

功能建议

PageHelper6.1.0搭配jsqlparser4.5使用,把项目打成war包之后部署到测试环境独立的tomcat中,结果一启动就报异常了,然而在IDEA开发环境中启动却一点事都没有,完全正常,真的是一不小心就蹦出一个坑来了。因为要更新生产环境,只好暂缓升级,回退到升级前正常的pagehelper-spring-boot-starter1.4.7(PageHelper5.3.3)版本了。

nyable commented 1 week ago

今天才发现这个坑。IDEA里跑的正常,打成jar包后跑就报一样的错。

LSL1618 commented 1 week ago

今天才发现这个坑。IDEA里跑的正常,打成jar包后跑就报一样的错。

建议版本降级吧