java.lang.NoSuchMethodError: com.google.common.collect.Sets.newConcurrentHashSet

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/36249002/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-03 01:08:22  来源:igfitidea点击:

java.lang.NoSuchMethodError: com.google.common.collect.Sets.newConcurrentHashSet

javajarcassandra

提问by srai

I am trying to use the sstableloader for bulk loading to Cassandra. I am trying to use code from here : https://github.com/yukim/cassandra-bulkload-example

我正在尝试使用 sstableloader 批量加载到 Cassandra。我正在尝试使用这里的代码:https: //github.com/yukim/cassandra-bulkload-example

I run into java.lang.NoSuchMethodError: com.google.common.collect.Sets.newConcurrentHashSet exception during running of application. The application imports the following libraries :

我在应用程序运行期间遇到 java.lang.NoSuchMethodError: com.google.common.collect.Sets.newConcurrentHashSet 异常。该应用程序导入以下库:

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.List;

import org.supercsv.io.CsvListReader;
import org.supercsv.prefs.CsvPreference;

import org.apache.cassandra.config.Config;
import org.apache.cassandra.dht.Murmur3Partitioner;
import org.apache.cassandra.exceptions.InvalidRequestException;
import org.apache.cassandra.io.sstable.CQLSSTableWriter;

The exception is coming from the following line of code :

异常来自以下代码行:

    // Prepare SSTable writer
CQLSSTableWriter.Builder builder = CQLSSTableWriter.builder();

I am using the following external jars for my application :

我正在为我的应用程序使用以下外部 jars:

super-csv-2.0.0.jar
cassandra-all-3.4.jar
gradle-wrapper.jar
slf4j-api-1.7.19.jar
concurrentlinkedhashmap-lru-1.3.jar
slf4j-simple-1.7.19.jar
guava.jar
google-collections-1.0.jar

I am unable to figure which libraries i am missing.

我无法确定我缺少哪些库。

enter image description here

在此处输入图片说明

Digging into com.google.comman.collect.Sets i cannot find the newConcurrentHashSet method. However the code seems to be calling it

深入研究 com.google.comman.collect.Sets 我找不到 newConcurrentHashSet 方法。但是代码似乎在调用它

enter image description here

在此处输入图片说明

回答by gustf

You should remove google-collections-1.0.jar.

你应该删除google-collections-1.0.jar.

Google Collection is renamed to Guava so you have multiple implementation of the same classes. And the "old" implementation of com.google.common.collect.Setsdoes not have this method and thats why you get the NoSuchMethodError.

Google Collection 已重命名为 Guava,因此您可以有多个相同类的实现。而 的“旧”实现com.google.common.collect.Sets没有这种方法,这就是为什么你得到NoSuchMethodError.

https://code.google.com/archive/p/google-collections/

https://code.google.com/archive/p/google-collections/