Java GAE+;Gradle:为什么没有名为“的方法?”;fetchAsync();在“;com.google.appengine.api.urlfetch.URLFetchService“;?
我是GAE的新手。我想使用fetch的异步版本(包“com.google.appengine.api.urlfetch.*”),根据api文档,该版本名为“fetchAsync()”,如下所示: 但在我的java代码中,似乎没有名为“fetchAsync()”的方法——它说“无法解析方法'fetchAsync(com.google.appengine.api.urlfetch.HTTPRequest)”。下面是我的java代码:Java GAE+;Gradle:为什么没有名为“的方法?”;fetchAsync();在“;com.google.appengine.api.urlfetch.URLFetchService“;?,java,google-app-engine,build.gradle,Java,Google App Engine,Build.gradle,我是GAE的新手。我想使用fetch的异步版本(包“com.google.appengine.api.urlfetch.*”),根据api文档,该版本名为“fetchAsync()”,如下所示: 但在我的java代码中,似乎没有名为“fetchAsync()”的方法——它说“无法解析方法'fetchAsync(com.google.appengine.api.urlfetch.HTTPRequest)”。下面是我的java代码: URL url = new URL("https://www.b
URL url = new URL("https://www.bitesquad.com" + href);
HTTPRequest request = new HTTPRequest(url, HTTPMethod.GET);
HTTPResponse response = URLFetchServiceFactory.getURLFetchService().fetchAsync(request);
我确信我导入了所需的所有内容,因为可以运行“fetch()”。我在想,如果我的build.gradle中没有包含GAE的适当版本,或者我遗漏了任何内容。或者谷歌没有更新文档?下面是我的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
提前谢谢你 我找到了答案:将版本更改为最新版本,如下所示:
compile group: 'com.google.appengine', name: 'appengine-api-1.0-sdk', version: '1.9.53'
(从1.2到1.9)在下面的线程中查看渐变脚本>