elastic-job-lite因为guava版本不同启动报错

最近项目需要使用elastic-job-lite来完成定时任务功能

引入对应的jar包后,包括guava 20.0版本。每次项目启动后报错:

com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor()Lcom/google/common/util/concurrent/ListeningExecutorService

具体报错信息如下:

***************************
APPLICATION FAILED TO START
***************************

Description:

An attempt was made to call a method that does not exist. The attempt was made from the following location:

    org.apache.curator.framework.listen.ListenerContainer.addListener(ListenerContainer.java:41)

The following method did not exist:

    com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor()Lcom/google/common/util/concurrent/ListeningExecutorService;

The method's class, com.google.common.util.concurrent.MoreExecutors, is available from the following locations:

    jar:file:/Users/dushan/.m2/repository/com/google/guava/guava/30.1-jre/guava-30.1-jre.jar!/com/google/common/util/concurrent/MoreExecutors.class

The class hierarchy was loaded from the following locations:

    com.google.common.util.concurrent.MoreExecutors: file:/Users/user/.m2/repository/com/google/guava/guava/30.1-jre/guava-30.1-jre.jar


其实根本原因就是因为java项目引入的jar包中,其中包含了多个版本的guava版本的jar包。

解决方法:
1.打开idea的terminal ,输入命令:查看jar包依赖

mvn dependency:tree

2.可以看到项目中guava版本:
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

2.根据这个依赖树,找到依赖guava包的jar包。
找到对应的jar包,配置maven的executions

对于我的项目而言,我是使用elastic-job-lite导致项目启动报错,并且报错的内容是guava的版本guava-30.1-jre.jar
那么我找到引用这个jar包的是nacos-client,解决方式如下
在这里插入图片描述

			<dependency>
            <groupId>com.alibaba.nacos</groupId>
            <artifactId>nacos-client</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>com.google.guava</groupId>
                    <artifactId>guava</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值