迁移到适用于 App Engine 的 Cloud Endpoints Frameworks 2.0

Migrating to Cloud Endpoints Frameworks 2.0 for App Engine

我目前正在尝试从 Cloud Endpoints 1.0 迁移到 Cloud Endpoints Frameworks 2.0

我已按照此处列出的步骤操作: https://cloud.google.com/appengine/docs/java/endpoints/migrating?authuser=0

在我的 build.gradle 中,我替换了:

compile 'com.google.appengine:appengine-endpoints:1.9.42'
compile 'com.google.appengine:appengine-endpoints-deps:1.9.42'

与:

compile 'com.google.endpoints:endpoints-framework:2.0.0-beta.5'
compile 'javax.inject:javax.inject:1'

web.xml 中,我将 SystemServiceServlet 替换为 EndpointsServlet,将 /_ah/spi/* 替换为 /_ah/api/*

但是在编译时,出现以下错误:

Error:Execution failed for task ':myapp_backend:appengineEndpointsGetClientLibs'.
> There was an error running endpoints command get-client-lib: web.xml must have 1 (found:0) SystemServiceServlet servlet

我是不是漏掉了什么?

按照@saiyr 的要求进行编辑,这是我的build.gradle 文件:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.google.appengine:gradle-appengine-plugin:1.9.42'
    }
}

repositories {
    jcenter();
}

apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'appengine'

sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7

dependencies {
    // AppEngine
    appengineSdk 'com.google.appengine:appengine-java-sdk:1.9.42'
    compile 'javax.servlet:servlet-api:2.5'

    //  Cloud Endpoints
    compile 'com.google.appengine:appengine-endpoints:1.9.42'
    compile 'com.google.appengine:appengine-endpoints-deps:1.9.42'

    // Cloud Endpoints Frameworks
    // compile 'com.google.endpoints:endpoints-framework:2.0.0-beta.7'
    // compile 'javax.inject:javax.inject:1'

    // Project
    compile files('src/main/webapp/WEB-INF/lib/gson-2.3.1.jar')
    compile 'com.googlecode.objectify:objectify:5.1.9'
    compile 'com.ganyo:gcm-server:1.0.2'
    compile 'com.google.appengine.tools:appengine-gcs-client:0.5'
}

appengine {
    downloadSdk = true
    appcfg {
        oauth2 = true
    }
    endpoints {
        getClientLibsOnBuild = true
        getDiscoveryDocsOnBuild = true
    }
}

更新:

这里现在有一个详细说明转换过程的指南: https://github.com/GoogleCloudPlatform/endpoints-framework-gradle-plugin/blob/master/ANDROID_README.md

这里:https://cloud.google.com/endpoints/docs/frameworks/legacy/v1/java/migrating-android

由于 Gradle 插件正在更新,现在您需要注释 out/delete endpoints 片段,这样客户端库就不会在构建时生成。然后,如果您需要生成客户端库,请暂时 manually

您好,不知道您是否已修复它,但这解决了我的问题

编译'com.google.endpoints:endpoints-framework:2.0.0-beta.9'

新插件现已可用,过渡指南: https://github.com/GoogleCloudPlatform/endpoints-framework-gradle-plugin/blob/master/ANDROID_README.md

(或https://cloud.google.com/endpoints/docs/frameworks/legacy/v1/java/migrating-android

别忘了也遵循迁移指南: https://cloud.google.com/appengine/docs/java/endpoints/migrating?authuser=0