将Google App Engine端点迁移到Framework 2.0 - 无法访问端点API

时间:2017-08-13 07:16:11

标签: google-app-engine

我正在根据迁移文档将我的Google App Engine端点迁移到Framework 2.0(Java),并采用以下配置。

Project build.gradle

buildscript {
    repositories {
        mavenCentral()
        jcenter()
    }
    dependencies {
        //classpath 'com.android.tools.build:gradle:2.1.0'
        classpath 'com.android.tools.build:gradle:2.3.3'
        classpath 'com.google.gms:google-services:3.0.0'
        classpath 'com.google.guava:guava:19.0'
    }
}
allprojects {
    repositories {
        mavenCentral()
        jcenter()
    }
}
task clean(type: Delete) {
    delete rootProject.buildDir
}

Api build.gradle

buildscript {
repositories {
        mavenCentral()
        jcenter()
    }
    dependencies {
        //classpath 'com.google.appengine:gradle-appengine-plugin:1.9.28'    
        classpath 'com.google.cloud.tools:appengine-gradle-plugin:1.3.2'
        classpath 'com.google.cloud.tools:endpoints-framework-gradle-plugin:1.0.0'
    }
}    
repositories {
    jcenter();
    mavenCentral();
}    
apply plugin: 'java'
apply plugin: 'war'    
apply plugin: 'com.google.cloud.tools.appengine'
apply plugin: 'com.google.cloud.tools.endpoints-framework-server'    
sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7    
dependencies {
    //appengineSdk 'com.google.appengine:appengine-java-sdk:1.9.28'    
    providedCompile group: 'javax.servlet', name: 'servlet-api', version:'2.5'
    compile 'jstl:jstl:1.2'
    compile group: 'javax.inject', name: 'javax.inject', version: '1'    
    compile group: 'com.google.endpoints', name: 'endpoints-framework', version: '2.0.7'    
    compile group: 'com.google.appengine', name: 'appengine-api-1.0-sdk', version: '1.9.54'    
    compile 'com.google.appengine:appengine-endpoints:1.9.54'
    compile 'com.google.appengine:appengine-endpoints-deps:1.9.54'
    compile 'com.google.guava:guava:19.0'
    compile 'com.googlecode.objectify:objectify:5.1.12'
    compile 'javax.servlet:servlet-api:2.5'    
    compile group: 'com.google.appengine.tools', name: 'appengine-gcs-client', version: '0.6'
}    
appengine {    
    deploy {
        version = findProperty("appengine.deploy.version")    
        def promoteProp = findProperty("appengine.deploy.promote")
        if (promoteProp != null) {
            promote = new Boolean(promoteProp)
        }
    }
}    
endpointsServer {
    hostname = "myhostname"
}    
group = "group.name.endpoints"
version = 1

的web.xml

<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee">
    <filter>
        <filter-name>ObjectifyFilter</filter-name>
        <filter-class>com.googlecode.objectify.ObjectifyFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>ObjectifyFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    <servlet>
        <servlet-name>EndpointsServlet</servlet-name>
        <servlet-class>com.google.api.server.spi.EndpointsServlet</servlet-class>
        <init-param>
            <param-name>services</param-name>
            <param-value>com.my.MyEndpoint</param-value>
        </init-param>
    </servlet>
    <servlet-mapping>
        <servlet-name>EndpointsServlet</servlet-name>
        <url-pattern>/_ah/api/*</url-pattern>
    </servlet-mapping>    
    <welcome-file-list>
        <welcome-file>index.html</welcome-file>
    </welcome-file-list>
</web-app>

访问api时,我收到ff错误:

Aug 13, 2017 2:23:17 PM com.google.apphosting.utils.jetty.JettyLogger warn
WARNING: Error for /_ah/api/discovery/v1/apis/myApi/v1/rest
java.lang.NoSuchMethodError: com.google.api.server.spi.SystemService.builder()Lcom/google/api/server/spi/SystemService$Builder;
    at com.google.api.server.spi.EndpointsServlet.createSystemService(EndpointsServlet.java:122)

有谁知道导致这个问题的原因是什么?

谢谢。

更新 从api build.gradle文件中注释掉ff行似乎可以解决这个问题:

//compile 'com.google.appengine:appengine-endpoints:1.9.54'
//compile 'com.google.appengine:appengine-endpoints-deps:1.9.54'

0 个答案:

没有答案