maven如何解决jar包依赖冲突

1.背景

在ruoyi-vue项目集成Warm-Flow过程中,需要把mybatis升级为mybatis-plus,按照Warm-Flow常见问题中升级过程,遇到一个依赖冲突的问题,导致启动报错。

2.报错信息

报错信息比较多,但是要抓住重点,关键就在java.lang.NoClassDefFoundError: net/sf/jsqlparser/statement/select/SelectItem,这里意思就是没有找到SelectItem
类,他是在com.github.jsqlparser包里面的,但是正常来说肯定是能找到的,毕竟是组件内部自己调用的,肯定是测试通过了的。所以我们就大胆猜测,是由于一个jar引入了多个版本,生效的版本没有这个类,没生效的有。

Caused by: java.lang.NoClassDefFoundError: net/sf/jsqlparser/statement/select/SelectItem
	at com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor.<clinit>(PaginationInnerInterceptor.java:69)
	at com.ruoyi.framework.config.MybatisPlusConfig.paginationInnerInterceptor(MybatisPlusConfig.java:39)
	at com.ruoyi.framework.config.MybatisPlusConfig.mybatisPlusInterceptor(MybatisPlusConfig.java:26)
	at com.ruoyi.framework.config.MybatisPlusConfig$$EnhancerBySpringCGLIB$$3f80bf90.CGLIB$mybatisPlusInterceptor$2(<generated>)
	at com.ruoyi.framework.config.MybatisPlusConfig$$EnhancerBySpringCGLIB$$3f80bf90$$FastClassBySpringCGLIB$$e2db53ed.invoke(<generated>)
	at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244)
	at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:331)
	at com.ruoyi.framework.config.MybatisPlusConfig$$EnhancerBySpringCGLIB$$3f80bf90.mybatisPlusInterceptor(<generated>)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154)
	... 96 common frames omitted
Caused by: java.lang.ClassNotFoundException: net.sf.jsqlparser.statement.select.SelectItem
	at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	... 109 common frames omitted

3.解决思路

3.1.查找jsqlparser冲突

  • 通过idea的Maven Helper插件查看有哪些冲突

3.2.发现冲突

  • 我们能看到jsqlparser存在多个版本,通过快捷键ctrl+n快捷得知,4.5版本是没有SelectItem类的,4.9才有
  • 所以我们需要保留4.9,排除4.5

3.2.解决冲突

  • 我们找到引入pagehelper-spring-boot-starterjar包的地方,排除低版本
        <dependency>
            <groupId>com.github.pagehelper</groupId>
            <artifactId>pagehelper-spring-boot-starter</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>com.github.jsqlparser</groupId>
                    <artifactId>jsqlparser</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

4.Dromara Warm-Flow

是不是通过WarmFlow工作流可以很简单的管理你的审批业务呢,还不快快加入v

另外Dromara组织还有大量好用的项目,欢迎评鉴

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值