阅读背景:

在Eclipse中为Cloud Endpoints类生成API元数据时出错

来源:互联网 

I have two different cloud endpoint methods with two different name signatures

我有两个不同的云端点方法,有两个不同的名称签名

@ApiMethod(name = "getWhiteCats", httpMethod = HttpMethod.POST)
 public CollectionResponse<Cat> getWhiteCats(CatCall request)

And

@ApiMethod(name = "getGrayCats", httpMethod = HttpMethod.POST)
public CollectionResponse<Cat> getGrayCats(CatCall request)

But Eclipse is giving the exception

但Eclipse正在例外

Description Resource Location Path Type There was a problem generating the API metadata for your Cloud Endpoints classes: com.google.api.server.spi.config.validation.DuplicateRestPathException: Multiple methods with same rest path "POST collectionresponse_cat":"getWhiteCats" and "getGrayCats"

说明资源位置路径类型生成Cloud Endpoints类的API元数据时出现问题:com.google.api.server.spi.config.validation.DuplicateRestPathException:具有相同休息路径的多个方法“POST collectionresponse_cat”:“getWhiteCats”和“getGrayCats”

Any thoughts on how I might resolve this issue?

有关如何解决此问题的任何想法?

2 个解决方案

#1


0  

I solved this issue by passing one more parameter in the @apiMethod annotation for example in your case

我通过在@apiMethod注释中再传递一个参数来解决这个问题,例如在你的情况下

@ApiMethod(name = "getWhiteCats", path="Somepath_realted_to_your_service", httpMethod = HttpMethod.POST)

@ApiMethod(name =“getWhiteCats”,path =“Somepath_realted_to_your_service”,httpMethod = HttpMethod.POST)

#2


0  

You need to specify a path for your methods with path = "yourPathHere". It should look something like this:

您需要使用path =“yourPathHere”为方法指定路径。它应该看起来像这样:

@ApiMethod(name = "getWhiteCats", path = "getWhiteCats", httpMethod = HttpMethod.POST)
 public CollectionResponse getWhiteCats(CatCall request)

and

@ApiMethod(name = "getGrayCats", path = "getGrayCats", httpMethod = HttpMethod.POST)
public CollectionResponse getGrayCats(CatCall request)

The path doesn't have to be the name of your @ApiMethod but I highly recommend it.

该路径不一定是@ApiMethod的名称,但我强烈推荐它。


分享到: