[英]Java GAE + Gradle: Why is there no method called “fetchAsync()” in “com.google.appengine.api.urlfetch.URLFetchService"?
I am new to GAE. 我是GAE的新手。 I would like to use the asynchronous version of fetch (of package "com.google.appengine.api.urlfetch.*"), which is named "fetchAsync()" according to API documentation at here: https://cloud.google.com/appengine/docs/standard/java/javadoc/com/google/appengine/api/urlfetch/URLFetchService 我想使用异步版本的fetch(程序包“ com.google.appengine.api.urlfetch。*”),根据API文档(此处为https://cloud.google )将其命名为“ fetchAsync()”。 的.com /应用服务引擎/文档/标准/ JAVA /的Javadoc / COM /谷歌/应用服务引擎/ API /网址抓取/ URLFetchService
But in my java code, it seems no method named "fetchAsync()" -- it says "Cannot resolve method 'fetchAsync(com.google.appengine.api.urlfetch.HTTPRequest)". 但是在我的Java代码中,似乎没有名为“ fetchAsync()”的方法-它说“无法解析方法'fetchAsync(com.google.appengine.api.urlfetch.HTTPRequest)”。 Below is my java code: 以下是我的Java代码:
URL url = new URL("https://www.bitesquad.com" + href);
HTTPRequest request = new HTTPRequest(url, HTTPMethod.GET);
HTTPResponse response = URLFetchServiceFactory.getURLFetchService().fetchAsync(request);
I am sure that I imported everything needed because it is okay to run "fetch()". 我确定我导入了所需的所有内容,因为可以运行“ fetch()”。 I am thinking about if I didn't include the appropriate version of GAE in my build.gradle or I missed anything in it. 我在考虑是否在build.gradle中没有包含适当版本的GAE,或者我什么都没错过。 Or maybe Google didn't update the documentation? 也许Google没有更新文档? Below is my build.gradle: 以下是我的build.gradle:
buildscript { // Configuration for building
repositories {
jcenter() // Bintray's repository - a fast Maven Central mirror & more
mavenCentral()
}
dependencies {
classpath 'com.google.cloud.tools:appengine-gradle-plugin:+' // latest App Engine Gradle tasks
}
}
repositories { // repositories for Jar's you access in your code
maven {
url 'https://maven-central.storage.googleapis.com' // Google's mirror of Maven Central
// url 'https://oss.sonatype.org/content/repositories/snapshots' // SNAPSHOT Repository (if needed)
}
jcenter()
mavenCentral()
}
apply plugin: 'java' // standard Java tasks
apply plugin: 'war' // standard Web Archive plugin
apply plugin: 'com.google.cloud.tools.appengine' // App Engine tasks
dependencies {
providedCompile group: 'javax.servlet', name: 'servlet-api', version:'2.5'
compile 'com.google.appengine:appengine:+'
compile "org.apache.httpcomponents:httpclient:4.5.3"
compile "org.apache.commons:commons-lang3:3.5"
compile "com.google.code.gson:gson:2.8.0"
// https://mvnrepository.com/artifact/com.google.appengine/appengine-api-1.0-sdk
compile group: 'com.google.appengine', name: 'appengine-api-1.0-sdk', version: '1.2.0'
testCompile 'junit:junit:4.12'
testCompile group: 'junit', name: 'junit', version: '4.12'
}
appengine { // App Engine tasks configuration
run { // local (dev_appserver) configuration (standard environments only)
port = 8080 // default
}
deploy { // deploy configuration
stopPreviousVersion = true // default - stop the current version
promote = true // default - & make this the current version
}
//tools.cloudSdkHome = '/Applications/google-cloud-sdk'
}
group 'xxx'
version 'xxx'
sourceCompatibility = 1.7 // App Engine Standard uses Java 7
targetCompatibility = 1.7 // App Engine Standard uses Java 7
Thank you in advance! 先感谢您!
I found the answer: change the version to the newest one as follows: 我找到了答案:将版本更改为最新版本,如下所示:
compile group: 'com.google.appengine', name: 'appengine-api-1.0-sdk', version: '1.9.53'
(from 1.2 to 1.9) (从1.2到1.9)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.