[英]“java.lang.NoSuchMethodError” exception is thrown on using Spreadsheet Service
I am using following code to fetch the spreadsheet and to print the title of sheet. 我正在使用以下代码来获取电子表格并打印工作表的标题。
import com.google.gdata.client.spreadsheet.*;
import com.google.gdata.data.spreadsheet.*;
import com.google.gdata.util.*;
import java.io.IOException;
import java.net.*;
import java.util.*;
public class MySpreadsheetIntegration {
public static void main(String[] args)
throws AuthenticationException, MalformedURLException, IOException, ServiceException {
SpreadsheetService service =
new SpreadsheetService("MySpreadsheetIntegration-v1");
URL SPREADSHEET_FEED_URL = new URL(
"spreadsheet URL");
SpreadsheetFeed feed = service.getFeed(SPREADSHEET_FEED_URL, SpreadsheetFeed.class);
List<SpreadsheetEntry> spreadsheets = feed.getEntries();
for (SpreadsheetEntry spreadsheet : spreadsheets) {
// Print the title of this spreadsheet to the screen
System.out.println(spreadsheet.getTitle().getPlainText());
}
}
}
but i am getting exception as follows: 但我得到如下异常:
Exception in thread "main" java.lang.NoSuchMethodError: com.google.common.collect.ImmutableSet.copyOf([Ljava/lang/Object;)Lcom/google/common/collect/ImmutableSet;
at com.google.gdata.wireformats.AltFormat$Builder.setAcceptableTypes(AltFormat.java:399)
at com.google.gdata.wireformats.AltFormat$Builder.setAcceptableXmlTypes(AltFormat.java:387)
at com.google.gdata.wireformats.AltFormat.<clinit>(AltFormat.java:49)
at com.google.gdata.client.Service.<clinit>(Service.java:558)
at myPackage.MySpreadsheetIntegration.main(MySpreadsheetIntegration.java:23)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
I didn't find any reason for this error, please help me to solve the problem to fetch the spreadsheet data. 我没有发现此错误的任何原因,请帮助我解决该问题以获取电子表格数据。
I am using following main jars: 我正在使用以下主要罐子:
gdata-spreadsheet-3.0
mailapi.jar
gdata-core-1.0
etc 等等
com.google.common.collect
is part of the Guava: Google Core Libraries for Java 1.6+ . com.google.common.collect
是Guava:Java 1.6+的Google核心库的一部分。 You probably need to download and install them ... guava-17.0.jar
would appear to be the latest version of the guava jar ... 您可能需要下载并安装它们...
guava-17.0.jar
似乎是guava jar的最新版本...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.