我正在创建谷歌云端点api,我正在尝试使用
apiKeyRequired = AnnotationBoolean.TRUE
的示例
@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无法解析此属性。
@ApiMethod(
name = "get",
path = "name/{id}",
httpMethod = ApiMethod.HttpMethod.GET,
apikeyRequired = AnnotationBoolean.TRUE)
我反编译了ApiMethod注释,它没有apikeyRequired属性
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() {
}
}
}
答案 0 :(得分:1)
之前我遇到过同样的问题。您需要确保删除所有旧的app-engine-endpoints依赖项并使用新的endpoint-framework
// Some definitions first...
typedef boost::asio::io_service::strand cb_strand;
typedef std::shared_ptr< cb_strand > cb_strand_ptr;
答案 1 :(得分:0)
你需要把k大写。也就是说,apiKeyRequired
,而不是apikeyRequired
。