我试图使用flickrj向Flickr发送一个ping测试。我将一步一步地遵循这里的教程
https://github.com/callmeal/Flickr4Java
导入所有maven依赖项和所有内容,并以以下代码结束:
import java.util.Collections;
import com.flickr4java.flickr.Flickr;
import com.flickr4java.flickr.REST;
import com.flickr4java.flickr.collections.Collection;
import com.flickr4java.flickr.test.TestInterface;
public class hello {
public static void main(String args[]){
String apiKey = "3f7046fe0897516df587cc3e6226f878";
String sharedSecret = "9d0ceef5f2f3040f";
Flickr f = new Flickr(apiKey, sharedSecret, new REST());
TestInterface testInterface = f.getTestInterface();
Collection results = testInterface.echo(Collections.EMPTY_MAP);
}
}但是,我得到了以下错误:
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
Type mismatch: cannot convert from Collection<Element> to Collection
at hello.main(hello.java:18)我做错了什么?
发布于 2015-08-11 08:51:25
您可能在导入中有冲突,您使用的是com.flickr4java.flickr.collections.Collection,而您很可能--作为回声方法返回类型状态--希望使用java.util.Collection类。将这一行改为:
java.util.Collection<Element> results = testInterface.echo(Collections.EMPTY_MAP);你的守则:
import java.util.Collections;
import com.flickr4java.flickr.Flickr;
import com.flickr4java.flickr.REST;
import com.flickr4java.flickr.collections.Collection;
import com.flickr4java.flickr.test.TestInterface;
public class hello {
public static void main(String args[]){
String apiKey = "3f7046fe0897516df587cc3e6226f878";
String sharedSecret = "9d0ceef5f2f3040f";
Flickr f = new Flickr(apiKey, sharedSecret, new REST());
TestInterface testInterface = f.getTestInterface();
java.util.Collection<Element> results = testInterface.echo(Collections.EMPTY_MAP);
}
}发布于 2015-08-11 08:40:11
根据文档这里,您需要转换为
Collection<Element> results = testInterface.echo(Collections.EMPTY_MAP);签名是..。
public Collection<Element> echo(Map<String, String> params) throws FlickrException {
....
return response.getPayloadCollection();
}https://stackoverflow.com/questions/31936746
复制相似问题