2017-06-21 113 views
0

我的問題已經在這裏找到答案: apiKeyRequired in google cloud endpoint not getting resolved在谷歌「apiKeyRequired」雲終端沒有得到解決(2日)

但它沒有爲我工作。

我仍然有這個問題,即IDE無法解析apiKeyRequired屬性。我正在使用端點框架2. +。

@Api(
     name = "api", 
     version = "v1", 
     apiKeyRequired = AnnotationBoolean.TRUE, 
     namespace = @ApiNamespace(
       ownerDomain = "backendDomain.myapplication.test.example.com", 
       ownerName = "backendName.myapplication.test.example.com", 
       packagePath = "" 
     ) 
) 
public class MyEndpoint { 
... 

的build.gradle

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

sourceCompatibility = JavaVersion.VERSION_1_7 
targetCompatibility = JavaVersion.VERSION_1_7 

dependencies { 
    appengineSdk 'com.google.appengine:appengine-java-sdk:1.9.54' 

    compile 'javax.servlet:servlet-api:2.5' 

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

    compile 'com.google.endpoints:endpoints-framework:2.0.7' 
} 
... 

回答

0

明白了!試圖解決問題幾個小時後!發佈此問題後,解決方案直接發送。

問題在於使用的依賴關係。在文件的build.gradle這兩個依賴所造成的問題:

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

我取而代之的是這兩個新的依賴條件:

compile 'com.google.endpoints:endpoints-management-control-appengine:1.0.3' 
compile 'com.google.endpoints:endpoints-framework-auth:1.0.3' 

的build.gradle(更新):

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

sourceCompatibility = JavaVersion.VERSION_1_7 
targetCompatibility = JavaVersion.VERSION_1_7 

dependencies { 
    appengineSdk 'com.google.appengine:appengine-java-sdk:1.9.54' 

    compile 'javax.servlet:servlet-api:2.5' 

    compile 'com.google.endpoints:endpoints-framework:2.0.7' 
    compile 'com.google.endpoints:endpoints-management-control-appengine:1.0.3' 
    compile 'com.google.endpoints:endpoints-framework-auth:1.0.3' 
} 
...