小编Joh*_*uza的帖子

尝试在 Quarkus 中进行 REST 调用时出错

我正在尝试在我拥有的另一项服务上执行请求。我用来创建应用程序的指南是:

QUARKUS - 使用 REST 客户端

QUARKUS - CDI 参考

QUARKUS - 研讨会

我收到如下错误:

org.jboss.resteasy.spi.UnhandledException: java.lang.RuntimeException: Error injecting com.easy.ecomm.core.product.ProductClient com.easy.ecomm.core.cart.CartService.productClient

org.eclipse.microprofile.rest.client.RestClientDefinitionException: Parameters and variables don't match on interface com.easy.ecomm.core.product.ProductClient::findProductById
Run Code Online (Sandbox Code Playgroud)

这是 ProductClient 类

import org.eclipse.microprofile.rest.client.inject.RegisterRestClient;

@Path("products")
@RegisterRestClient(configKey = "products-api")
public interface ProductClient {

    @GET
    @Path("{id}")
    Product findProductById(String id);

}

Run Code Online (Sandbox Code Playgroud)

这是服务层:

import org.eclipse.microprofile.rest.client.inject.RestClient;

import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;

@ApplicationScoped
public class CartService {

    @Inject
    @RestClient
    ProductClient productClient;

    public void addItem(String cartId, String productId, Integer amount){
        // Code to find the cart on a …
Run Code Online (Sandbox Code Playgroud)

java rest cdi quarkus-rest-client

2
推荐指数
1
解决办法
5160
查看次数

标签 统计

cdi ×1

java ×1

quarkus-rest-client ×1

rest ×1