生成端点库时GAE中的DuplicateRestPathException

时间:2013-12-15 09:20:49

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

我正在使用JAVA Google App Engine构建后端。我创建了3种api方法,都非常相似。

定义是这样的:

@ApiMethod(name = "getGamesOffThePodium")
    public CollectionResponse<MGameResult> getGamesOffThePodium(@Nullable @Named("cursor") String cursorString, @Nullable @Named("limit") Integer limit) {
}

@ApiMethod(name = "getGamesWon")
    public CollectionResponse<MGameResult> getGamesWon(@Nullable @Named("cursor") String cursorString, @Nullable @Named("limit") Integer limit) {
    }

@ApiMethod(name = "getGamesUnsolved")
    public CollectionResponse<MGameResult> getGamesUnsolved(@Nullable @Named("cursor") String cursorString, @Nullable @Named("limit") Integer limit) {
}

这里是Eclipse在我尝试生成云端点客户端库时给出的异常:

enter image description here

为什么?我不能有3个方法返回相同对象的集合吗?

1 个答案:

答案 0 :(得分:4)

您可以让多个对象返回相同的对象。您需要在注释中添加“path”属性。

@ApiMethod(name = "getGamesOffThePodium", path = "get_games_off_the_podium")
    public CollectionResponse<MGameResult> getGamesOffThePodium(@Nullable @Named("cursor") String cursorString, @Nullable @Named("limit") Integer limit) {
}

@ApiMethod(name = "getGamesWon", path = "get_games_won")
    public CollectionResponse<MGameResult> getGamesWon(@Nullable @Named("cursor") String cursorString, @Nullable @Named("limit") Integer limit) {
    }

@ApiMethod(name = "getGamesUnsolved", path = "get_games_unsolved")
    public CollectionResponse<MGameResult> getGamesUnsolved(@Nullable @Named("cursor") String cursorString, @Nullable @Named("limit") Integer limit) {
}