Google App Engine无法识别@Named参数

时间:2016-09-20 22:44:43

标签: google-app-engine

我正在使用Google Plugin for Eclipse,我正在Eclipse WTP中将App Engine应用程序编写为动态Web模块。

我已将以下Java类定义为Cloud Endpoint API:

package mypackage;

import static mypackage.OfyService.ofy;

import java.util.List;
import java.util.logging.Logger;

import mypackage.models.ProbeEntry;
import mypackage.models.ProbeSet;

import com.google.api.server.spi.config.Api;
import com.google.api.server.spi.config.ApiMethod;
import com.google.api.server.spi.config.ApiNamespace;
import com.google.api.server.spi.config.Named;
import com.googlecode.objectify.ObjectifyService;

@Api(name = "analysisEndpoint", 
    version = "v1", 
    namespace = @ApiNamespace(
                                ownerDomain = "myorg", 
                                ownerName = "myorg", 
                                packagePath = "analysis")
        )
public class AnalysisEndpoint {

    private static final Logger logger = Logger.getLogger(AnalysisEndpoint.class.getName());

    @ApiMethod(name = "getMyProbeEntries", httpMethod = ApiMethod.HttpMethod.GET)
    public ProbeSet getMyProbeEntries(@Named("amount") int amount) {
        ObjectifyService.begin();

        List<ProbeEntry> probeList = ofy().load().type(ProbeEntry.class).limit(amount).list();

        return new ProbeSet(probeList);
    }
}

我尝试通过右键单击项目来部署到Google App Engine - &gt; Google App Engine WTP - &gt;将项目部署到远程服务器。我在我的控制台中看到该项目正在编译和上传,但最终出现错误:

99% Endpoints configuration not updated.  The app returned an error when the Google Cloud Endpoints server attempted to communicate with it.

应用引擎上的错误日志显示以下内容:

18:31:58.119
javax.servlet.ServletContext log: unavailable
com.google.api.server.spi.config.validation.MissingParameterNameException: analysisEndpoint.myorg.analysis.AnalysisEndpoint.getMyProbeEntries parameter (type int): Missing parameter name. Parameter type (int) is not an entity type and thus should be annotated with @Named.
        at     
com.google.api.server.spi.config.validation.ApiConfigValidator.validateApiParameter(ApiConfigValidator.java:214)
        ...

从代码中可以看出,我在违规参数之前有@Named("amount")。这里出了什么问题?附注:如果我只是删除amount参数,项目就可以毫无问题地部署到App Engine。

非常感谢任何帮助。

0 个答案:

没有答案