choerodon-starter-mybatis-mapper使用最新版本jsqlparser报错

  • Choerodon平台版本:0.10.0

  • 运行环境(如localhost或k8s):localhost

  • 遇到问题时的前置条件:

      使用Sql Server 2016
    
  • 问题描述:

    如:在启动服务过程中,启动报错
    Error starting ApplicationContext. To display the auto-configuration report re-run your application with ‘debug’ enabled.
    2018-11-12 16:09:46.387 ERROR [hzero-platform,] 38532 — [ main] o.s.boot.SpringApplication : Application startup failed

org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘dialect’ defined in class path resource [io/choerodon/mybatis/MybatisMapperAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [io.choerodon.mybatis.pagehelper.Dialect]: Factory method ‘dialect’ threw exception; nested exception is java.lang.NoSuchMethodError: net.sf.jsqlparser.statement.select.Top.setRowCount(J)V
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:599) ~[spring-beans-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1173) ~[spring-beans-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1067) ~[spring-beans-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513) ~[spring-beans-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) ~[spring-beans-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761) ~[spring-beans-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:866) ~[spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542) ~[spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:737) [spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:370) [spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:314) [spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1162) [spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1151) [spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
at org.hzero.platform.Application.main(Application.java:31) [classes/:na]
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [io.choerodon.mybatis.pagehelper.Dialect]: Factory method ‘dialect’ threw exception; nested exception is java.lang.NoSuchMethodError: net.sf.jsqlparser.statement.select.Top.setRowCount(J)V
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189) ~[spring-beans-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588) ~[spring-beans-4.3.8.RELEASE.jar:4.3.8.RELEASE]
… 18 common frames omitted
Caused by: java.lang.NoSuchMethodError: net.sf.jsqlparser.statement.select.Top.setRowCount(J)V
at io.choerodon.mybatis.pagehelper.parser.SqlServerParser.(SqlServerParser.java:78) ~[choerodon-starter-mybatis-mapper-0.6.4.RELEASE.jar:0.6.4.RELEASE]
at io.choerodon.mybatis.pagehelper.dialect.SqlServerDialect.(SqlServerDialect.java:48) ~[choerodon-starter-mybatis-mapper-0.6.4.RELEASE.jar:0.6.4.RELEASE]
at io.choerodon.mybatis.MybatisMapperAutoConfiguration.dialect(MybatisMapperAutoConfiguration.java:93) ~[hzero-starter-mybatis-mapper-0.3.0-20181108.074242-46.jar:0.3.0-SNAPSHOT]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_162]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_162]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_162]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_162]
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162) ~[spring-beans-4.3.8.RELEASE.jar:4.3.8.RELEASE]
… 19 common frames omitted

  • 原因分析:

    服务内升级了jsqlparser版本,用于解析sql而pageHelper不支持对应版本。

  • 建议:

    更新pageHelper版本,支持最新的jsqlparser版本

PageHelper文档上只支持到0.9.5版本的jsqlpaser,你用的啥版本。还有sqlserver数据库因为没有做过测试,可能会有一些问题,我们后续讨论是否兼容SqlServer数据库

    <dependency>
        <groupId>com.github.jsqlparser</groupId>
        <artifactId>jsqlparser</artifactId>
        <version>1.3</version>
    </dependency>用了这个版本。

那兼容时间点可以发下?

我们的排期优先级可能不太高,日期尚不明确。但是我们是开源项目,也欢迎你加入进来,可以到github上提merge requet :slight_smile: