谷歌云终端中的apiKeyRequired未得到解决 [英] apiKeyRequired in google cloud endpoint not getting resolved
本文介绍了谷歌云终端中的apiKeyRequired未得到解决的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在创建谷歌云端点API,我试图使用
I am creating google cloud endpoint api, I am trying to use
apiKeyRequired = AnnotationBoolean.TRUE
as an example on https://github.com/GoogleCloudPlatform/java-docs-samples/blob/master/appengine/endpoints-frameworks-v2/backend/src/main/java/com/example/echo/Echo.java
@ApiMethod(name = "echo_api_key", path = "echo_api_key", apiKeyRequired =AnnotationBoolean.TRUE)
public Message echoApiKey(Message message, @Named("n") @Nullable Integer n) {
return doEcho(message, n);
}
我的代码是这样的。 IDE无法解析此属性。
My code is this. IDE is not able to resolve this attribute.
@ApiMethod(
name = "get",
path = "name/{id}",
httpMethod = ApiMethod.HttpMethod.GET,
apikeyRequired = AnnotationBoolean.TRUE)
我反编译ApiMethod注解,它没有apikeyRequired属性
I decompiled the ApiMethod annotation, It don't have apikeyRequired attribute
package com.google.api.server.spi.config;
import com.google.api.server.spi.config.ApiMethodCacheControl;
import com.google.api.server.spi.config.AuthLevel;
import com.google.api.server.spi.config.Authenticator;
import com.google.api.server.spi.config.PeerAuthenticator;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD})
public @interface ApiMethod {
String name() default "";
String path() default "";
String httpMethod() default "";
/** @deprecated */
@Deprecated
ApiMethodCacheControl cacheControl() default @ApiMethodCacheControl;
AuthLevel authLevel() default AuthLevel.UNSPECIFIED;
String[] scopes() default {"_UNSPECIFIED_LIST_STRING_VALUE"};
String[] audiences() default {"_UNSPECIFIED_LIST_STRING_VALUE"};
String[] clientIds() default {"_UNSPECIFIED_LIST_STRING_VALUE"};
Class<? extends Authenticator>[] authenticators() default {Authenticator.class};
Class<? extends PeerAuthenticator>[] peerAuthenticators() default {PeerAuthenticator.class};
public static class HttpMethod {
public static final String GET = "GET";
public static final String POST = "POST";
public static final String PUT = "PUT";
public static final String DELETE = "DELETE";
public HttpMethod() {
}
}
}
推荐答案
之前我有同样的问题。您需要确保删除所有旧的应用程序引擎端点依赖项,并使用新的端点框架。
I had the same issue before. You need to make sure to remove all old app-engine-endpoints dependencies and use the new endpoint-framework
compile group: 'com.google.endpoints', name: 'endpoints-framework', version: '2.0.+'
这篇关于谷歌云终端中的apiKeyRequired未得到解决的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文