Java 未解析google云端点中的apiKeyRequired
我正在创建google云端点api,我正在尝试使用Java 未解析google云端点中的apiKeyRequired,java,google-app-engine,annotations,google-cloud-endpoints,Java,Google App Engine,Annotations,Google Cloud Endpoints,我正在创建google云端点api,我正在尝试使用 apiKeyRequired = AnnotationBoolean.TRUE 例如 我的密码是这个。IDE无法解析此属性 @ApiMethod( name = "get", path = "name/{id}", httpMethod = ApiMethod.HttpMethod.GET, apikeyRequired = AnnotationBoolean.TRUE)
apiKeyRequired = AnnotationBoolean.TRUE
例如
我的密码是这个。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() {
}
}
}
package com.google.api.server.spi.config;
导入com.google.api.server.spi.config.ApiMethodCacheControl;
导入com.google.api.server.spi.config.AuthLevel;
导入com.google.api.server.spi.config.Authenticator;
导入com.google.api.server.spi.config.PeerAuthenticator;
导入java.lang.annotation.ElementType;
导入java.lang.annotation.Retention;
导入java.lang.annotation.RetentionPolicy;
导入java.lang.annotation.Target;
@保留(RetentionPolicy.RUNTIME)
@目标({ElementType.METHOD})
公共@接口方法{
字符串名()默认为“”;
字符串路径()默认为“”;
字符串httpMethod()默认为“”;
/**@弃用*/
@不赞成
ApiMethodCacheControl cacheControl()默认值@ApiMethodCacheControl;
AuthLevel AuthLevel()默认AuthLevel.UNSPECIFIED;
String[]scopes()默认值{“\u未指定的\u列表\u字符串\u值”};
字符串[]访问群体()默认值{“\u未指定的\u列表\u字符串\u值”};
字符串[]clientId()默认值{“\u未指定的\u列表\u字符串\u值”};
类您需要大写k。也就是说,apiKeyRequired
,而不是apiKeyRequired
,我以前也遇到过同样的问题。您需要确保删除所有旧的app engine端点依赖项,并使用新的端点框架
compile group: 'com.google.endpoints', name: 'endpoints-framework', version: '2.0.+'
apiKeyRequired属性是在Cloud Endpoints Framework 2.0中添加的。请检查您的依赖项:com.google.Endpoints:Endpoints Framework:2.0.0(旧版本类似于com.google.appengine:appengine Endpoints:1.x.x)
compile group: 'com.google.endpoints', name: 'endpoints-framework', version: '2.0.+'