rest客户端子资源在调用时返回abstractmethoderror

k2arahey  于 2021-09-13  发布在  Java
关注(0)|答案(0)|浏览(123)

根据我对quarkus中可用的微文件rest客户端的理解,我应该能够在我的rest客户端接口中定义子资源,这将允许我像这样将资源嵌套在彼此下面。

package org.acme.example

import org.eclipse.microprofile.rest.client.inject.RegisterRestClient;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;

@RegisterRestClient
@Path("/api/foo")
public interface FoosService {
    @GET
    @Produces(MediaType.APPLICATION_JSON)
    List<Foo> getAll();

    @Path("/{id}")
    FooService foo(@PathParam("id") String id);
}

public interface FooService {
    @GET
    @Produces(MediaType.APPLICATION_JSON)
    Foo toRepresentation();
}

然而,当我在代码中注入并调用客户机接口时,它会抛出 AbstractMethodErrorclient.foo("bar").toRepresentation() 呼叫

@Path("/bar")
public class BarResource {
    @RestClient
    FoosResource client;

    @GET
    @Produces(MediaType.APPLICATION_JSON)
    public Foo getBar() {
        return client.foo("bar").toRepresentation();
    }
}

我对此的所有研究似乎都表明这是可能的,但quarkus没有显示客户端子资源的具体示例。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题