我正在尝试玩!应用程序通过 GData API 从 Youtube 获取数据。按照 Youtube 指南我添加了
import com.google.gdata.client.*;
import com.google.gdata.client.youtube.*;
import com.google.gdata.data.*;
import com.google.gdata.data.geo.impl.*;
import com.google.gdata.data.media.*;
import com.google.gdata.data.media.mediarss.*;
import com.google.gdata.data.youtube.*;
import com.google.gdata.data.extensions.*;
import com.google.gdata.util.*;
import java.io.IOException;
import java.io.File;
import java.net.URL;
到我的文件顶部,然后创建我的类
public class Videos extends Controller {
//...Irrelevant stuff...
public static void create(@Required String video_id) {
if (validation.hasErrors()) {
render("Videos/submit.html");
}
YouTubeService service = new YouTubeService("app", "abcd");
String videoEntryURL = "http://gdata.youtube.com/feeds/api/videos/"+video_id;
VideoEntry videoEntry = service.getEntry(new URL(videoEntryURL), VideoEntry.class);
System.out.println(videoEntry.getTitle().getPlainText());
}
//...Irrelevant stuff...
}
我在 Play 中收到以下错误
Compilation error
The file /app/controllers/Videos.java could not be compiled. Error raised is : The type com.google.gdata.client.media.MediaService cannot be resolved. It is indirectly referenced from required .class files In /app/controllers/Videos.java (around line 40)
40: VideoEntry videoEntry = service.getEntry(new URL(videoEntryURL), VideoEntry.class);
在浏览器中
play.exceptions.CompilationException: The type com.google.gdata.client.media.MediaService cannot be resolved. It is indirectly referenced from required .class files at play.classloading.ApplicationCompiler$2.acceptResult(ApplicationCompiler.java:246) at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:474) at play.classloading.ApplicationCompiler.compile(ApplicationCompiler.java:278) at play.classloading.ApplicationClassloader.getAllClasses(ApplicationClassloader.java:412) at play.Play.start(Play.java:485) at play.Play.detectChanges(Play.java:599) at play.Invoker$Invocation.init(Invoker.java:186) at Invocation.HTTP Request(Play!)
从命令行。
我最近才开始使用 Play!但这个错误让我难住了=/
我已将 GData api 中的两个必需库添加到我的 Play! 的/lib/文件夹中。应用程序,我遵循的 GData API 指南是 here
最佳答案
com.google.gdata.client.media.MediaService 位于 gdata-media-[版本].jar 中。在我的项目中,我有五个 gdata jar:gdata-base、gdata-client、gdata-media、gdata-youtube 和 gdata-core。
关于java - 使用 Google Youtube API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8173523/