由于pagehelper和mybatisplus-core中分页插件版本冲突导致mybatisplus启动报错
项目启动报错:
The following method did not exist:
net.sf.jsqlparser.schema.Column.withColumnName(Ljava/lang/String;)Lnet/sf/jsqlparser/schema/Column;
经过分析如下图的报错信息发现, 是mybatisplus在调用jsqlparser中的withColumnName方法的时候方法不存在
分析报错日志, 判断大概是jar包冲突导致版本不一致, 进而导致低版本的jsqlparser类中没有withColumnName方法, 导致报错
上图明显能看出跟interceptor有关, 而整个项目中只有在mybatis配置类中用过interceptor, 用做拦截分页, 将其注掉发现不再报错, 项目正常启动, 但是mybatis自动分页失效, 显然是不能这样解决的
那么我们只能从处理冲突入手, 使用maven的分析依赖工具查看冲突, 如下图所示
经过如上分析, 可以看出是mybatis-plus-extension与pagehelper中的jsqlparser冲突导致, 故进入pom文件找到pagehelper, 由于他引用的jsqlparser为2.0是低版本使用exclusion标签将pagehelper中的jsqlparser排除, 任何刷新maven
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper</artifactId>
<exclusions>
<exclusion>
<groupId>com.github.jsqlparser</groupId>
<artifactId>jsqlparser</artifactId>
</exclusion>
</exclusions>
<version>5.1.11</version>
</dependency>
再次进入依赖分析查看, jsqlparser版本已经变为4.4版本与mybatis-plus-extension一致
再次尝试, 启动项目成功!
总结: 由于mybatis-plus-extension和pagehelper都使用到了jsqlparser, 从而引入了不同版本,导致版本冲突。