簡體   English   中英

使用電子表格服務會引發“ java.lang.NoSuchMethodError”異常

[英]“java.lang.NoSuchMethodError” exception is thrown on using Spreadsheet Service

我正在使用以下代碼來獲取電子表格並打印工作表的標題。

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());
        }

    }
}

但我得到如下異常:

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)

我沒有發現此錯誤的任何原因,請幫助我解決該問題以獲取電子表格數據。

我正在使用以下主要罐子:

gdata-spreadsheet-3.0
mailapi.jar
gdata-core-1.0 

等等

com.google.common.collectGuava:Java 1.6+的Google核心庫的一部分。 您可能需要下載並安裝它們... guava-17.0.jar似乎是guava jar的最新版本...

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM