Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/google-app-engine/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
谷歌自定义搜索api Java_Java_Google App Engine - Fatal编程技术网

谷歌自定义搜索api Java

谷歌自定义搜索api Java,java,google-app-engine,Java,Google App Engine,我正在尝试使用google自定义java搜索api,但由于某些原因,它不起作用。以下是我的java代码: String searchText = "football"; String key="mykey"; String cx = "mygeneratedcx"; HttpRequestInitializer httpRequestInitializer = new HttpRequestInitializer() { @Override publi

我正在尝试使用google自定义java搜索api,但由于某些原因,它不起作用。以下是我的java代码:

 String searchText = "football";
    String key="mykey";
    String cx = "mygeneratedcx";

   HttpRequestInitializer httpRequestInitializer = new HttpRequestInitializer() {

    @Override
    public void initialize(HttpRequest request) throws IOException {

    }
};
JsonFactory jsonFactory = new JacksonFactory();

   Customsearch custom = new Customsearch(new NetHttpTransport(), jsonFactory,            httpRequestInitializer);
    Customsearch.Cse.List list = custom.cse().list("football");
    list.setCx(cx);
    list.setKey(key);

   Search result = list.execute();

  List listResult = (List) result.getItems();
 Result first = (Result) listResult.get(0);
这些是我使用api的依赖项:

<dependency>
<groupId>com.google.api.client</groupId>
<artifactId>google-api-client-http</artifactId>
<version>1.2.3-alpha</version>
</dependency>

<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-customsearch</artifactId>
<version>v1-rev30-1.17.0-rc</version>
</dependency>
我看过一些例子,但它们与我得到的api的ASE版本不符。 执行上述代码时,我收到以下异常:

主线程java.lang.NoSuchMethodError中出现异常:com.google.api.client.util.Strings.isNullOrEmptyLjava/lang/String;Z 在com.google.api.client.googleapis.services.AbstractGoogleClient上

如果有人使用过这个针对java的google定制搜索api,我将非常感谢您的帮助


提前谢谢你

问题解决了。我已使用以下内容更改了google api客户端的依赖关系: com.google.http-client 谷歌http客户端jackson 1.15.0-rc