Java – Method of using Google Eclipse Plug-in in Google cloud endpoints

I encountered a strange behavior when using the Google App Engine Eclipse Plug-in to generate endpoints I have an endpoint class with 20 endpoint methods When I first tried to generate an endpoint for Android, I got an error

Generating Cloud Endpoint has encountered errors and is not complete

Through troubleshooting, I will annotate all the methods to find the culprit I found it a little confusing. After canceling the 16th method, I received the error again There are two ways to interfere with each other! If I annotate one or another endpoint, a penalty is generated But if I don't have comments, I will receive the above error

Who knows that this interference may be caused?

@ApiMethod(name = "getOrangers",httpMethod = HttpMethod.POST)
public FaceList getOrangers(UserRequest request) throws NotFoundException {
    FaceList list = new FaceList();
    return list;
}

@ApiMethod(name = "getMangoers",httpMethod = HttpMethod.POST)
public FaceList getMangoers(UserRequest request) throws NotFoundException {
    FaceList list = new FaceList();
    return list;
}

I have edited the methods into their stubs, as shown above, and still get the same interference problem

Solution

First, when you find this annoying and unnecessary message, you make an error:

You should check the error log under the window – > display view – > error log for more information

When I do this, I find that the actual exceptions are:

java.lang.IllegalArgumentException: 
  Multiple methods with same rest path "POST facelist": "getOrangers" and "getMangoers"

So the problem is that your two methods have the same path! Specifying the path to add a method will solve the problem:

@ApiMethod(name="getOrangers",path="get_oranges",httpMethod=HttpMethod.POST)
public FaceList getOrangers(UserRequest request) throws NotFoundException {
    //...
}

@ApiMethod(name="getMangoers",path="get_mangoers",httpMethod=HttpMethod.POST)
public FaceList getMangoers(UserRequest request) throws NotFoundException {
    //...
}

Note: since you have not set a path for the method, GPE will be generated automatically It seems that GPE is generating the same path for the two methods to form the path of HTTP method (post) and return value (facelist), which is inconsistent with what is said in Google cloud endpoints documentation:

It means that the path is automatically generated using the method name. In this case, you won't receive any errors because your two methods have significantly different names So I think this must be a bug in endpoints (like many people)

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>