创建PicasawebService

时间:2012-05-16 11:14:47

标签: netbeans picasa

我尝试从公共Picasa相册中获取标题和网址。但我一开始就陷入困境:我无法创建新的PicasawebService。

我的代码:

import java.util.List;
import java.io.File;
import java.net.URL;

import com.google.gdata.client.*;
import com.google.gdata.client.photos.*;
import com.google.gdata.data.*;
import com.google.gdata.data.media.*;
import com.google.gdata.data.photos.*;
import java.util.ArrayList;

public class PicasaManager implements PicasaConnector {

    public List<Avatar> getPhotoURLs() throws Exception {
        PicasawebService myService = new PicasawebService("HI");

        myService.setUserCredentials("foo@gmail.com", "mypassword");

        ArrayList<Avatar> rl = new ArrayList<Avatar>();

        URL feedUrl = new URL("https://picasaweb.google.com/111420671758947023853/EWA2012");
        System.out.println("dddddddddddddddddd");
        AlbumFeed feed = myService.getFeed(feedUrl, AlbumFeed.class);

        for (PhotoEntry photo : feed.getPhotoEntries()) {
            Avatar a1 = new Avatar();
            a1.setDescription(photo.getTitle().getPlainText());
            a1.setUrl(photo.getMediaThumbnails().get(0).getUrl());
            rl.add(a1);
        }

        return (rl);
    }
}

错误讯息:

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 tuwien.big.mensch.utilities.PicasaManager.getPhotoURLs(PicasaManager.java:27)
    at tuwien.big.mensch.utilities.test.main(test.java:29)
  • test.java是我的测试类,带有public static void main方法,
  • 阿凡达是一个有两个变量的类:description和url,两者都有getter和setter
  • 在我的netbeans IDE第27行的PicasaManager.java文件中:PicasawebService myService = new PicasawebService(“HI”);
  • 实现的interace仅定义getPhotoURLs()方法

我不知道如何解决这个问题,我希望有人可以帮助我。

1 个答案:

答案 0 :(得分:0)

您是否包含了gdata-core-1.0.jar和guava-12.0.jar?祝其他Web Engineering UE4好运; - )