【问题标题】:appEngine cloud endpoint single parameter issueappEngine 云端点单参数问题
【发布时间】:2017-04-13 21:06:40
【问题描述】:

Google Cloud Endpoint 不允许您在调用中拥有多个参数。因此,例如,以下将不起作用

@ApiMethod(name = "addFriend", httpMethod = ApiMethod.HttpMethod.POST)
    public void addFriend(Friend frient, User user) throws OAuthRequestException {
        ...
    }

问题是 OAuth 要求我除了通常的参数之外还有一个用户参数。那我该怎么写呢?

【问题讨论】:

  • 嗨,这实际上应该可以正常工作。您只能有一个 resource 参数,但用户不应算作资源。你真的尝试过吗?如果是,你得到了什么输出?
  • 当我这样做时,整个方法在 android studio 中变为红色(下划线)。留言:Multiple entity parameters. There can only be a single entity parameter per method. Checks that a specified resource parameter for a class that does not have a transformer is not a multi-level collection or an array and does not use @Named
  • 我也在使用import com.google.api.server.spi.auth.common.User
  • 你使用的是哪个框架版本?

标签: java google-app-engine oauth-2.0 google-cloud-endpoints


【解决方案1】:

它在 Android Studio 中显示为错误,但在您使用 Maven 部署时可以正常工作! Studio for Cloud Endpoints 框架 v2 中的 Guess Gradle 插件支持将解决此检查。目前,使用@SuppressWarnings("ResourceParameter")。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-06-29
    • 2014-09-27
    • 1970-01-01
    • 1970-01-01
    • 2019-08-15
    相关资源
    最近更新 更多