将Guava升级到最新的23.5,获得Preconditions.checkArgument的NoSuchMethodError

问题描述 投票:0回答:2

在将番石榴升级到23.5-jre的最新18.0时,我得到了如下例外情况

Exception in thread "main" java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkArgument(ZLjava/lang/String;Ljava/lang/Object;)V
    at com.van.common.VanExecutors.getSpec(VanExecutors.java:91)
    at com.van.common.VanExecutors.newFixedSizeExecutor(VanExecutors.java:114)
    at com.van.storage.config.ConfigStoreFactory.getOrCreateUncachedStore(ConfigStoreFactory.java:56)
    at com.van.storage.config.ConfigStoreFactory.getOrCreateStore(ConfigStoreFactory.java:74)
    at com.van.storage.config.PolicyManager.loadFromSystemProperties(PolicyManager.java:79)
    at com.van.tools.metric.HbaseMetricStoreSetup.main(HbaseMetricStoreSetup.java:25)

相关代码

private ExecutorSpec getSpec(String executorName) {
        Preconditions.checkArgument(isValid(), "Not initialized");
        Preconditions.checkArgument(NullOrEmpty.isFalse(executorName), "No executor name given");
        Preconditions.checkArgument(POOL_NAME_PATTERN.matcher(executorName).matches(), "Executor name %s must end with -exec", executorName);
        for (ExecutorSpec spec : executorsSpec.getExecutorSpecList()) {
            if (spec.getName().equalsIgnoreCase(executorName)) return spec;
        }
        return null;
    }

根据堆栈跟踪线91是最后一个前提条件检查。

有人能让我知道出了什么问题吗?

java java-8 guava
2个回答
0
投票

在我看来,方法isValid()返回String(这是改变?)但boolean is expected(和在release 18 too)。


0
投票

为了解决这个问题,我用CLASSPATH(export CLASSPATH=<guava-23.5>;$CLASSPATH)和Guava 23.5 jre作为前缀。

© www.soinside.com 2019 - 2024. All rights reserved.